Module: Blamestamp::Blameable::ClassMethods

Defined in:
lib/blamestamp/active_record.rb

Instance Method Summary collapse

Instance Method Details

#blameable(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/blamestamp/active_record.rb', line 10

def blameable(options = {})
  c = options_to_config(options)
  class_attribute :blameable_config
  self.blameable_config = c

  # associations
  self.belongs_to c[:cre_user], :class_name => c[:class], :foreign_key => c[:cre_by]
  self.belongs_to c[:upd_user], :class_name => c[:class], :foreign_key => c[:upd_by]

  # callbacks
  self.before_create :blame_create
  self.before_update :blame_update
  self.after_destroy :blame_destroy
end