Module: Kvbean::Observing
- Defined in:
- lib/kvbean/observing.rb
Constant Summary collapse
- CALLBACKS =
]
[ :before_create, :before_destroy, :before_save, :before_update, :after_create, :after_destroy, :after_save, :after_update ]
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kvbean/observing.rb', line 13 def self.included(base) base.send :include, ActiveModel::Observing CALLBACKS.each do |callback| callback_method = :"notify_observers_#{callback}" base.class_eval <<-RUBY, __FILE__, __LINE__ + 1 #{callback}(#{callback_method.inspect}) def #{callback_method}(&block) notify_observers(#{callback.inspect}, &block) end private #{callback_method.inspect} RUBY end end |