Class: Workflow::State
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#name ⇒ Object
Returns the value of attribute name.
-
#on_entry ⇒ Object
Returns the value of attribute on_entry.
-
#on_exit ⇒ Object
Returns the value of attribute on_exit.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #<=>(other_state) ⇒ Object
-
#initialize(name, spec, meta = {}) ⇒ State
constructor
A new instance of State.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name, spec, meta = {}) ⇒ State
Returns a new instance of State.
88 89 90 |
# File 'lib/workflow.rb', line 88 def initialize(name, spec, = {}) @name, @spec, @events, @meta = name, spec, Hash.new, end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
85 86 87 |
# File 'lib/workflow.rb', line 85 def events @events end |
#meta ⇒ Object
Returns the value of attribute meta.
85 86 87 |
# File 'lib/workflow.rb', line 85 def @meta end |
#name ⇒ Object
Returns the value of attribute name.
85 86 87 |
# File 'lib/workflow.rb', line 85 def name @name end |
#on_entry ⇒ Object
Returns the value of attribute on_entry.
85 86 87 |
# File 'lib/workflow.rb', line 85 def on_entry @on_entry end |
#on_exit ⇒ Object
Returns the value of attribute on_exit.
85 86 87 |
# File 'lib/workflow.rb', line 85 def on_exit @on_exit end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
86 87 88 |
# File 'lib/workflow.rb', line 86 def spec @spec end |
Instance Method Details
#<=>(other_state) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/workflow.rb', line 95 def <=>(other_state) states = spec.states.keys raise ArgumentError, "state `#{other_state}' does not exist" unless other_state.in? states if states.index(self.to_sym) < states.index(other_state.to_sym) -1 elsif states.index(self.to_sym) > states.index(other_state.to_sym) 1 else 0 end end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/workflow.rb', line 108 def to_s "#{name}" end |
#to_sym ⇒ Object
112 113 114 |
# File 'lib/workflow.rb', line 112 def to_sym name.to_sym end |