Class: Workflow::HelperMethodConfigurator
- Inherits:
-
Object
- Object
- Workflow::HelperMethodConfigurator
- Defined in:
- lib/workflow/helper_method_configurator.rb
Instance Attribute Summary collapse
-
#workflow_class ⇒ Object
readonly
Returns the value of attribute workflow_class.
-
#workflow_spec ⇒ Object
readonly
Returns the value of attribute workflow_spec.
Instance Method Summary collapse
- #configure! ⇒ Object
- #create_instance_methods ⇒ Object
-
#initialize(workflow_spec, workflow_class) ⇒ HelperMethodConfigurator
constructor
A new instance of HelperMethodConfigurator.
Constructor Details
#initialize(workflow_spec, workflow_class) ⇒ HelperMethodConfigurator
Returns a new instance of HelperMethodConfigurator.
6 7 8 9 |
# File 'lib/workflow/helper_method_configurator.rb', line 6 def initialize(workflow_spec, workflow_class) @workflow_spec = workflow_spec @workflow_class = workflow_class end |
Instance Attribute Details
#workflow_class ⇒ Object (readonly)
Returns the value of attribute workflow_class.
4 5 6 |
# File 'lib/workflow/helper_method_configurator.rb', line 4 def workflow_class @workflow_class end |
#workflow_spec ⇒ Object (readonly)
Returns the value of attribute workflow_spec.
4 5 6 |
# File 'lib/workflow/helper_method_configurator.rb', line 4 def workflow_spec @workflow_spec end |
Instance Method Details
#configure! ⇒ Object
11 12 13 14 15 |
# File 'lib/workflow/helper_method_configurator.rb', line 11 def configure! undefine_methods_defined_by_workflow_spec if inherited_workflow_spec? define_revert_events if workflow_spec.define_revert_events? create_instance_methods end |
#create_instance_methods ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/workflow/helper_method_configurator.rb', line 17 def create_instance_methods workflow_spec.states.each do |state| state_name = state.name workflow_class.module_eval do define_method "#{state_name}?" do state_name == current_state.name end end state.events.each do |event| define_method_for_event(event) unless event_method?(event) end end end |