Module: Transitions::ClassMethods

Defined in:
lib/transitions.rb

Instance Method Summary collapse

Instance Method Details

#available_eventsObject



55
56
57
# File 'lib/transitions.rb', line 55

def available_events
  @state_machine.events.keys.sort
end

#available_statesObject



51
52
53
# File 'lib/transitions.rb', line 51

def available_states
  @state_machine.states.map(&:name).sort_by {|x| x.to_s}
end

#get_state_machineObject



49
# File 'lib/transitions.rb', line 49

def get_state_machine; @state_machine; end

#inherited(klass) ⇒ Object



34
35
36
37
# File 'lib/transitions.rb', line 34

def inherited(klass)
  super # Make sure we call other callbacks possibly defined upstream the ancestor chain.
  klass.state_machine = state_machine
end

#state_machine(options = {}, &block) ⇒ Object



44
45
46
47
# File 'lib/transitions.rb', line 44

def state_machine(options = {}, &block)
  @state_machine ||= Machine.new self
  block ? @state_machine.update(options, &block) : @state_machine
end

#state_machine=(value) ⇒ Object

The only reason we need this method is for the inherited callback.



40
41
42
# File 'lib/transitions.rb', line 40

def state_machine=(value)
  @state_machine = value.dup
end