Module: SimpleStates::ClassMethods

Defined in:
lib/simple_states.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#initial_stateObject

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

#newObject



19
20
21
# File 'lib/simple_states.rb', line 19

def new(*)
  super.tap { |object| object.init_state }
end

#state?(state) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/simple_states.rb', line 28

def state?(state)
  states.include?(state)
end

#statesObject



32
33
34
# File 'lib/simple_states.rb', line 32

def states
  [initial_state] + self::States.states
end