Module: ActiveCouch::Callbacks
- Defined in:
- lib/active_couch/callbacks.rb
Constant Summary collapse
- CALLBACKS =
%w(before_save after_save before_delete after_delete)
Class Method Summary collapse
Instance Method Summary collapse
- #after_delete ⇒ Object
- #after_save ⇒ Object
- #before_delete ⇒ Object
-
#before_save ⇒ Object
end method self.included.
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_couch/callbacks.rb', line 5 def self.included(base) # Alias methods which will have callbacks, (for now only save and delete). # This creates 2 pairs of methods: save_with_callbacks, save_without_callbacks, # delete_with_callbacks, delete_without_callbacks # # save_without_callbacks and delete_without_callbacks # have the same behaviour as the save and delete methods, respectively [:save, :delete].each do |method| base.send :alias_method_chain, method, :callbacks end CALLBACKS.each do |method| base.class_eval " def self.\#{method}(*callbacks, &block)\n callbacks << block if block_given?\n # Assumes that the default value for the callbacks hash in the\n # including class is an empty array\n self.callbacks[\#{method.to_sym.inspect}] = self.callbacks[\#{method.to_sym.inspect}] + callbacks\n end\n end_eval\n end\nend\n" |
Instance Method Details
#after_delete ⇒ Object
34 |
# File 'lib/active_couch/callbacks.rb', line 34 def after_delete() end |
#after_save ⇒ Object
30 |
# File 'lib/active_couch/callbacks.rb', line 30 def after_save() end |
#before_delete ⇒ Object
32 |
# File 'lib/active_couch/callbacks.rb', line 32 def before_delete() end |
#before_save ⇒ Object
end method self.included
28 |
# File 'lib/active_couch/callbacks.rb', line 28 def before_save() end |