Module: FunctionalLightService::Action::Macros
- Defined in:
- lib/functional-light-service/action.rb
Instance Method Summary collapse
- #executed ⇒ Object
- #expected_keys ⇒ Object
- #expects(*args) ⇒ Object
- #promised_keys ⇒ Object
- #promises(*args) ⇒ Object
- #rolled_back ⇒ Object
Instance Method Details
#executed ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/functional-light-service/action.rb', line 35 def executed define_singleton_method :execute do |context = {}| action_context = create_action_context(context) return action_context if action_context.stop_processing? # Store the action within the context action_context.current_action = self Context::KeyVerifier.verify_keys(action_context, self) do action_context.define_accessor_methods_for_keys(all_keys) catch(:jump_when_failed) do call_before_action(action_context) yield(action_context) call_after_action(action_context) end end end end |
#expected_keys ⇒ Object
27 28 29 |
# File 'lib/functional-light-service/action.rb', line 27 def expected_keys @expected_keys ||= [] end |
#expects(*args) ⇒ Object
19 20 21 |
# File 'lib/functional-light-service/action.rb', line 19 def expects(*args) expected_keys.concat(args) end |
#promised_keys ⇒ Object
31 32 33 |
# File 'lib/functional-light-service/action.rb', line 31 def promised_keys @promised_keys ||= [] end |
#promises(*args) ⇒ Object
23 24 25 |
# File 'lib/functional-light-service/action.rb', line 23 def promises(*args) promised_keys.concat(args) end |
#rolled_back ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/functional-light-service/action.rb', line 55 def rolled_back msg = "`rolled_back` macro can not be invoked again" raise msg if respond_to?(:rollback) define_singleton_method :rollback do |context = {}| yield(context) context end end |