Module: CanTango::Config::Engines::Order

Included in:
CanTango::Config::Engines
Defined in:
lib/cantango/config/engines/order.rb

Instance Method Summary collapse

Instance Method Details

#clear_order!Object



5
6
7
# File 'lib/cantango/config/engines/order.rb', line 5

def clear_order!
  @execution_order = nil
end

#dont_execute(name) ⇒ Object



14
15
16
# File 'lib/cantango/config/engines/order.rb', line 14

def dont_execute name
  execution_order.delete(name.to_s)
end

#execute_after(existing, name) ⇒ Object



35
36
37
38
39
40
# File 'lib/cantango/config/engines/order.rb', line 35

def execute_after existing, name
  dont_execute name
  index = execution_order.index(existing.to_s)
  index ? execution_order.insert(index +1, name.to_s) : execute_last(name)
  execution_order.compact!
end

#execute_before(existing, name) ⇒ Object



28
29
30
31
32
33
# File 'lib/cantango/config/engines/order.rb', line 28

def execute_before existing, name
  dont_execute name
  index = execution_order.index(existing.to_s) || 0
  execution_order.insert(index, name.to_s)
  execution_order.compact!
end

#execute_first(name) ⇒ Object



18
19
20
21
# File 'lib/cantango/config/engines/order.rb', line 18

def execute_first name
  dont_execute name
  execution_order.insert(0, name.to_s)
end

#execute_last(name) ⇒ Object



23
24
25
26
# File 'lib/cantango/config/engines/order.rb', line 23

def execute_last name
  dont_execute name
  execution_order.insert(-1, name.to_s)
end

#execution_orderObject



42
43
44
# File 'lib/cantango/config/engines/order.rb', line 42

def execution_order
  @execution_order ||= (available - [:cache])
end

#set_execution_order(*names) ⇒ Object

defines the order of execution of engine in ability



10
11
12
# File 'lib/cantango/config/engines/order.rb', line 10

def set_execution_order *names        
  @execution_order = names.flatten.uniq.map(&:to_s).select {|name| available? name }
end