Module: CommandServiceObject::Hooks::InstanceMethods
- Defined in:
- lib/command_service_object/hooks.rb
Instance Attribute Summary collapse
-
#_called_micros ⇒ Object
Returns the value of attribute _called_micros.
Instance Method Summary collapse
Instance Attribute Details
#_called_micros ⇒ Object
Returns the value of attribute _called_micros.
19 20 21 |
# File 'lib/command_service_object/hooks.rb', line 19 def _called_micros @_called_micros end |
Instance Method Details
#rollback_micros ⇒ Object
25 26 27 |
# File 'lib/command_service_object/hooks.rb', line 25 def rollback_micros _called_micros.reverse_each(&:rollback) end |
#setup_micros(micros) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/command_service_object/hooks.rb', line 29 def setup_micros(micros) micros.each do |micro| method_name = micro.name.split('::').last.underscore # unrollable micros define_singleton_method("#{method_name}!") do |cmd| micro.new(cmd).call end # rollable micros define_singleton_method(method_name) do |cmd| obj = micro.new(cmd) result = obj.call _called_micros << obj result end end end |