Module: StateMachines::Machine::Callbacks
- Included in:
- StateMachines::Machine
- Defined in:
- lib/state_machines/machine/callbacks.rb
Instance Method Summary collapse
-
#after_failure(*args, **options) ⇒ Object
Creates a callback that will be invoked after a transition has failed to be performed.
-
#after_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked after a transition is performed so long as the given requirements match the transition.
-
#around_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked around a transition so long as the given requirements match the transition.
-
#before_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked before a transition is performed so long as the given requirements match the transition.
Instance Method Details
#after_failure(*args, **options) ⇒ Object
Creates a callback that will be invoked after a transition has failed to be performed.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/state_machines/machine/callbacks.rb', line 47 def after_failure(*args, **, &) # Extract legacy positional arguments and merge with keyword options = parse_callback_arguments(args, ) # Only validate callback-specific options, not state transition requirements = .slice(:do, :if, :unless, :bind_to_object, :terminator) StateMachines::OptionsValidator.assert_valid_keys!(, :do, :if, :unless, :bind_to_object, :terminator) add_callback(:failure, , &) end |
#after_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked after a transition is performed so long as the given requirements match the transition.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/state_machines/machine/callbacks.rb', line 21 def after_transition(*args, **, &) # Extract legacy positional arguments and merge with keyword options = parse_callback_arguments(args, ) # Only validate callback-specific options, not state transition requirements = .slice(:do, :if, :unless, :bind_to_object, :terminator) StateMachines::OptionsValidator.assert_valid_keys!(, :do, :if, :unless, :bind_to_object, :terminator) add_callback(:after, , &) end |
#around_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked around a transition so long as the given requirements match the transition.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/state_machines/machine/callbacks.rb', line 34 def around_transition(*args, **, &) # Extract legacy positional arguments and merge with keyword options = parse_callback_arguments(args, ) # Only validate callback-specific options, not state transition requirements = .slice(:do, :if, :unless, :bind_to_object, :terminator) StateMachines::OptionsValidator.assert_valid_keys!(, :do, :if, :unless, :bind_to_object, :terminator) add_callback(:around, , &) end |
#before_transition(*args, **options) ⇒ Object
Creates a callback that will be invoked before a transition is performed so long as the given requirements match the transition.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/state_machines/machine/callbacks.rb', line 8 def before_transition(*args, **, &) # Extract legacy positional arguments and merge with keyword options = parse_callback_arguments(args, ) # Only validate callback-specific options, not state transition requirements = .slice(:do, :if, :unless, :bind_to_object, :terminator) StateMachines::OptionsValidator.assert_valid_keys!(, :do, :if, :unless, :bind_to_object, :terminator) add_callback(:before, , &) end |