Module: Commutator::Model::Hooks::ClassMethods
- Defined in:
- lib/commutator/model/hooks.rb
Instance Method Summary collapse
- #add_before_hook(operation, *method_names) ⇒ Object
- #before_hooks ⇒ Object
- #run_before_hooks(operation, options) ⇒ Object
Instance Method Details
#add_before_hook(operation, *method_names) ⇒ Object
21 22 23 24 25 |
# File 'lib/commutator/model/hooks.rb', line 21 def add_before_hook(operation, *method_names) method_names.each do |method_name| before_hooks[operation] << method_name end end |
#before_hooks ⇒ Object
27 28 29 |
# File 'lib/commutator/model/hooks.rb', line 27 def before_hooks @before_hooks ||= Hash.new { |h, k| h[k] = [] } end |
#run_before_hooks(operation, options) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/commutator/model/hooks.rb', line 31 def run_before_hooks(operation, ) before_hooks[operation].each do |method_name| send(method_name, ) end end |