Module: AASM

Defined in:
lib/aasm/aasm.rb,
lib/aasm/event.rb,
lib/aasm/state.rb,
lib/aasm/persistence.rb,
lib/aasm/state_machine.rb,
lib/aasm/state_transition.rb,
lib/aasm/persistence/active_record_persistence.rb

Defined Under Namespace

Modules: ClassMethods, Persistence, SupportingClasses Classes: InvalidTransition, StateMachine, UndefinedState

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



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

def self.included(base) #:nodoc:
  base.extend AASM::ClassMethods
  AASM::Persistence.set_persistence(base)
  unless AASM::StateMachine[base]
    AASM::StateMachine[base] = AASM::StateMachine.new('')
  end
end

.VersionObject



7
8
9
# File 'lib/aasm/aasm.rb', line 7

def self.Version
  '2.1.1'
end

Instance Method Details

#aasm_current_stateObject

Instance methods



84
85
86
87
88
89
90
91
92
# File 'lib/aasm/aasm.rb', line 84

def aasm_current_state
  return @aasm_current_state if @aasm_current_state

  if self.respond_to?(:aasm_read_state) || self.private_methods.include?('aasm_read_state')
    @aasm_current_state = aasm_read_state
  end
  return @aasm_current_state if @aasm_current_state
  aasm_determine_state_name(self.class.aasm_initial_state)
end

#aasm_events_for_current_stateObject



94
95
96
# File 'lib/aasm/aasm.rb', line 94

def aasm_events_for_current_state
  aasm_events_for_state(aasm_current_state)
end

#aasm_events_for_state(state) ⇒ Object



98
99
100
101
# File 'lib/aasm/aasm.rb', line 98

def aasm_events_for_state(state)
  events = self.class.aasm_events.values.select {|event| event.transitions_from_state?(state) }
  events.map {|event| event.name}
end