Forked from jescalante/sequel_model_without_a_table.rb
Created
October 10, 2012 21:17
-
-
Save jeremyevans/3868477 to your computer and use it in GitHub Desktop.
Trying to use a sequel model without a table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in sequel/plugins/foo.rb | |
module Sequel::Plugin::Foo | |
def self.apply(model) | |
model.plugin :timestamps, :create => :created_on, :update => :updated_on | |
model.plugin :validation_helpers | |
model.many_to_one :user | |
end | |
module InstanceMethods | |
# Note that it's probably a bad idea to override initialize unless you | |
# really know what you are doing. | |
def initialize(params={}) ... end | |
# Make sure to call super inside these methods. | |
def before_save ... end | |
def after_create ... end | |
def validate ... end | |
end | |
end | |
class Bar1 < Sequel::Model(:bar1) | |
plugin :foo | |
... | |
end | |
class Bar2 < Sequel::Model(:bar2) | |
plugin :foo | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment