Module: SimpleStates::ClassMethods
- Defined in:
- lib/simple_states.rb
Instance Attribute Summary collapse
-
#initial_state ⇒ Object
Returns the value of attribute initial_state.
Instance Method Summary collapse
Instance Attribute Details
#initial_state ⇒ Object
Returns the value of attribute initial_state.
17 18 19 |
# File 'lib/simple_states.rb', line 17 def initial_state @initial_state end |
Instance Method Details
#event(name, opts = {}) ⇒ Object
23 24 25 26 |
# File 'lib/simple_states.rb', line 23 def event(name, opts = {}) method = name == :all ? :update_events : :define_event self::States.send(method, name, opts) end |
#new ⇒ Object
19 20 21 |
# File 'lib/simple_states.rb', line 19 def new(*) super.tap { |object| object.init_state } end |
#state?(state) ⇒ Boolean
28 29 30 |
# File 'lib/simple_states.rb', line 28 def state?(state) states.include?(state) end |
#states ⇒ Object
32 33 34 |
# File 'lib/simple_states.rb', line 32 def states [initial_state] + self::States.states end |