Class: Jsm::EventExecutor::ActiveModel
- Defined in:
- lib/jsm/event_executor/active_model.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#can_be_executed?(event, obj) ⇒ Boolean
check if the obj possible to execute the event.
Methods inherited from Base
#execute, #execute!, #initialize
Constructor Details
This class inherits a constructor from Jsm::EventExecutor::Base
Instance Method Details
#can_be_executed?(event, obj) ⇒ Boolean
check if the obj possible to execute the event
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/jsm/event_executor/active_model.rb', line 3 def can_be_executed?(event, obj) state = event.can_be_transitioning_to(obj) attribute_name = obj.class.state_machine.attribute_name obj.valid? if state validators.validate(state.to, obj) else obj.errors.add(attribute_name, 'no transitions match') end obj.errors.empty? end |