Module: CouchPotato::Persistence::Callbacks
- Defined in:
- lib/couch_potato/persistence/callbacks.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/couch_potato/persistence/callbacks.rb', line 4 def self.included(base) base.extend ClassMethods base.class_eval do attr_accessor :skip_callbacks def self.callbacks @callbacks ||= {} @callbacks[self.name] ||= {:before_validation_on_create => [], :before_validation_on_update => [], :before_validation_on_save => [], :before_create => [], :after_create => [], :before_update => [], :after_update => [], :before_save => [], :after_save => [], :before_destroy => [], :after_destroy => []} end end end |
Instance Method Details
#run_callbacks(name) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/couch_potato/persistence/callbacks.rb', line 20 def run_callbacks(name) return if skip_callbacks self.class.callbacks[name].uniq.each do |callback| run_callback callback end end |