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
# 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
  state_container.state = new_state
end

.execute_action(action) ⇒ Object



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

def execute_action(action)
  action.execute
end

.get_instance(obj) ⇒ Object



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

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



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

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