7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/acts_as_blamable.rb', line 7
def acts_as_blamable(options={})
class_variable_set :@@bl_conf, { :current_user_method => :current_user, :class_name => 'User', :creator_foreign_key => :created_by, :updater_foreign_key => :updated_by }
bl_conf.update(options) if options.is_a? Hash
class_eval do
include ActsAsBlamable::InstanceMethods
belongs_to :creator, :foreign_key => bl_conf[:creator_foreign_key], :class_name => bl_conf[:class_name]
belongs_to :updater, :foreign_key => bl_conf[:updater_foreign_key], :class_name => bl_conf[:class_name]
before_create :save_creator
before_update :save_updater
end
end
|