Module: RailsStateMachine::Model::ClassMethods

Defined in:
lib/rails_state_machine/model.rb

Instance Method Summary collapse

Instance Method Details

#state_events(state_attribute = DEFAULT_STATE_ATTRIBUTE) ⇒ Object



30
31
32
# File 'lib/rails_state_machine/model.rb', line 30

def state_events(state_attribute = DEFAULT_STATE_ATTRIBUTE)
  state_machine(state_attribute).event_names
end

#state_machine(state_attribute = DEFAULT_STATE_ATTRIBUTE, prefix: '', &block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rails_state_machine/model.rb', line 17

def state_machine(state_attribute = DEFAULT_STATE_ATTRIBUTE, prefix: '', &block)
  state_machine = state_machines[state_attribute] ||= StateMachine.new(self, state_attribute, prefix: prefix)
  if block
    include(Callbacks) unless self < Callbacks
    state_machine.configure(&block)
  end
  state_machine
end

#states(state_attribute = DEFAULT_STATE_ATTRIBUTE) ⇒ Object



26
27
28
# File 'lib/rails_state_machine/model.rb', line 26

def states(state_attribute = DEFAULT_STATE_ATTRIBUTE)
  state_machine(state_attribute).state_names
end