Class: RMachine::CallEventMethodNotifier
- Inherits:
-
Object
- Object
- RMachine::CallEventMethodNotifier
- Defined in:
- lib/r_machine/notifiers/call_event_method_notifier.rb
Instance Attribute Summary collapse
-
#change_state_value_notifier ⇒ Object
readonly
Returns the value of attribute change_state_value_notifier.
-
#entity_with_state ⇒ Object
readonly
Returns the value of attribute entity_with_state.
-
#message_args ⇒ Object
readonly
Returns the value of attribute message_args.
-
#method_to_call ⇒ Object
readonly
Returns the value of attribute method_to_call.
-
#state_template ⇒ Object
readonly
Returns the value of attribute state_template.
Instance Method Summary collapse
-
#initialize(params) ⇒ CallEventMethodNotifier
constructor
A new instance of CallEventMethodNotifier.
- #notify! ⇒ Object
Constructor Details
#initialize(params) ⇒ CallEventMethodNotifier
Returns a new instance of CallEventMethodNotifier.
6 7 8 9 10 11 12 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 6 def initialize(params) @entity_with_state = params[:entity] @state_template = params[:state_template] @method_to_call = params[:method_to_call] @message_args = params[:message_args] @change_state_value_notifier = params[:change_state_value_notifier] end |
Instance Attribute Details
#change_state_value_notifier ⇒ Object (readonly)
Returns the value of attribute change_state_value_notifier.
3 4 5 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 3 def change_state_value_notifier @change_state_value_notifier end |
#entity_with_state ⇒ Object (readonly)
Returns the value of attribute entity_with_state.
3 4 5 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 3 def entity_with_state @entity_with_state end |
#message_args ⇒ Object (readonly)
Returns the value of attribute message_args.
3 4 5 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 3 def @message_args end |
#method_to_call ⇒ Object (readonly)
Returns the value of attribute method_to_call.
3 4 5 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 3 def method_to_call @method_to_call end |
#state_template ⇒ Object (readonly)
Returns the value of attribute state_template.
3 4 5 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 3 def state_template @state_template end |
Instance Method Details
#notify! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/r_machine/notifiers/call_event_method_notifier.rb', line 14 def notify! event = state_template.find_event(method_to_call) success = false event.rules.each do |rule| if rule.must_have_specific_state? if is_in_state?(rule.state_should_be) if rule.has_conditional? if execute_conditional_method(rule.conditional_method, ) == true change_current_state_value_to(rule.change_to) success = true end else change_current_state_value_to(rule.change_to) success = true end end else change_current_state_value_to(rule.change_to) success = true end break if success == true end raise StateTransactionNotPermittedError if success == false end |