Module: StateBoss
- Includes:
- EventHistory
- Defined in:
- lib/state_boss.rb,
lib/state_boss/version.rb,
lib/state_boss/event_history.rb
Defined Under Namespace
Modules: ClassMethods, EventHistory, Initializer
Classes: InvalidTransitionError, StateInitializationError
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Instance Method Summary
collapse
#event_history, #record_event
Class Method Details
.included(klass) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/state_boss.rb', line 10
def self.included(klass)
klass.extend ClassMethods
klass.prepend Initializer
klass.class_eval do
@default_state = nil
@events = {}
@transitions = {}
end
end
|
Instance Method Details
#current_state ⇒ Object
21
22
23
|
# File 'lib/state_boss.rb', line 21
def current_state
_state
end
|
#finished_state? ⇒ Boolean
30
31
32
|
# File 'lib/state_boss.rb', line 30
def finished_state?
next_states.nil?
end
|
#next_states ⇒ Object
25
26
27
28
|
# File 'lib/state_boss.rb', line 25
def next_states
transitions = self.class.instance_variable_get(:@transitions)
transitions[_state][:to]
end
|