Module: Yasm::Manager

Defined in:
lib/yasm/manager.rb

Class Method Summary collapse

Class Method Details

.change_state(options) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/yasm/manager.rb', line 5

def change_state(options)
  new_state       = options[:to]
  state_container = options[:on]
  state_time      = options[:at] || Time.now
  
  new_state = get_instance new_state
  new_state.instantiated_at = state_time
  new_state.context = state_container.context 
  state_container.state = new_state
end

.execute_action(action) ⇒ Object



27
28
29
# File 'lib/yasm/manager.rb', line 27

def execute_action(action)
  action.execute
end

.get_instance(obj) ⇒ Object



31
32
33
34
35
# File 'lib/yasm/manager.rb', line 31

def get_instance(obj)
  obj = obj.to_class if obj.respond_to? :to_class
  obj = obj.new if obj.class == Class
  obj
end

.setup_action(options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/yasm/manager.rb', line 16

def setup_action(options)
  action = options[:action]
  context = options[:context]
  state_container = options[:state_container]
  
  action = get_instance action
  action.context = context
  action.state_container = state_container
  action
end