Created
April 20, 2011 18:31
-
-
Save Porta/932239 to your computer and use it in GitHub Desktop.
This file contains 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
class Event < Ohm::Model | |
reference :user, lambda { |id| User.find(id)} | |
reference :item, lambda { |id| Item.find(id)} | |
reference :transaction, lambda { |id|Transaction.find(id)} | |
attribute :kind | |
attribute :text | |
attribute :created_at | |
index :user_id | |
index :item_id | |
index :transaction_id | |
index :created_at | |
KINDS = %w[registration creation reception delivery] | |
def validate | |
assert_present :kind | |
#KINDS = %w[registration creation reception delivery] | |
assert KINDS.include?(self.kind), [:kind, :not_valid] | |
#cheap before_create hook | |
self.created_at = Time.now | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment