Module: AASM
- Defined in:
- lib/aasm.rb,
lib/event.rb,
lib/state.rb,
lib/version.rb,
lib/persistence.rb,
lib/state_machine.rb,
lib/state_transition.rb,
lib/persistence/active_record_persistence.rb
Defined Under Namespace
Modules: ClassMethods, Persistence, SupportingClasses, VERSION
Classes: InvalidTransition, StateMachine, UndefinedState
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.Version ⇒ Object
7
8
9
|
# File 'lib/aasm.rb', line 7
def self.Version
'2.0.5.2'
end
|
Instance Method Details
#aasm_current_state ⇒ Object
85
86
87
88
89
90
91
92
93
|
# File 'lib/aasm.rb', line 85
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
self.class.aasm_initial_state
end
|
#aasm_event ⇒ Object
112
|
# File 'lib/aasm.rb', line 112
def aasm_event; @aasm_event; end
|
#aasm_event=(event) ⇒ Object
Added to allow forms to trigger events, perhaps I missed something, but this seemed neccesary -asoules
105
106
107
108
109
110
|
# File 'lib/aasm.rb', line 105
def aasm_event=(event)
if aasm_events_for_current_state.include?(event.to_sym)
@aasm_event = event
send(event)
end
end
|
#aasm_events_for_current_state(context = :all) ⇒ Object
95
96
97
|
# File 'lib/aasm.rb', line 95
def aasm_events_for_current_state(context=:all)
aasm_events_for_state(aasm_current_state, context)
end
|
#aasm_events_for_state(state, context = :all) ⇒ Object
99
100
101
102
|
# File 'lib/aasm.rb', line 99
def aasm_events_for_state(state, context=:all)
events = self.class.aasm_events.values.select {|event| event.transitions_from_state?(state, context) }
events.map {|event| event.name}
end
|