Class: StateManager::State::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/state_manager/state.rb

Overview

Represents the static specification of this state. This consists of all child states and events. During initialization, the specification will be read and the child states and events will be initialized.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpecification

Returns a new instance of Specification.



12
13
14
15
# File 'lib/state_manager/state.rb', line 12

def initialize
  self.states = {}
  self.events = {}
end

Instance Attribute Details

#eventsObject

Returns the value of attribute events.



10
11
12
# File 'lib/state_manager/state.rb', line 10

def events
  @events
end

#initial_stateObject

Returns the value of attribute initial_state.



10
11
12
# File 'lib/state_manager/state.rb', line 10

def initial_state
  @initial_state
end

#statesObject

Returns the value of attribute states.



10
11
12
# File 'lib/state_manager/state.rb', line 10

def states
  @states
end

Instance Method Details

#descendant_namesObject



22
23
24
25
26
27
28
29
# File 'lib/state_manager/state.rb', line 22

def descendant_names
  res = []
  states.each do |state, specification_klass|
    res << state
    res.concat specification_klass.specification.descendant_names.map{|s| "#{state}.#{s}"}
  end
  res
end

#initialize_copy(source) ⇒ Object



17
18
19
20
# File 'lib/state_manager/state.rb', line 17

def initialize_copy(source)
  self.states = source.states.dup
  self.events = source.events.dup
end