Class: Playmo::Action

Inherits:
Object show all
Defined in:
lib/playmo/action.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipe, &block) ⇒ Action

Returns a new instance of Action.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/playmo/action.rb', line 8

def initialize(recipe, &block)
  # Откладываем непосредственный запуск
  @@actions ||= []
  @@actions << [recipe, block]

  #recipe.instance_eval &block
  #puts "fuck" if block_given?
  #if block.arity > 0
  #  puts "We have args!"
  #  recipe.instance_eval &block
  #else
    #puts "It seems we have answers"
  #  instance_eval &block
  #end
end

Class Method Details

.execute_allObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/playmo/action.rb', line 24

def self.execute_all
  @@actions.each do |action|
  	recipe, block = action[0], action[1]
    
    recipe.class.class_eval do
      source_root "#{Playmo::ROOT}/recipes/templates/#{recipe.name}_recipe"
    end

    begin
  	  recipe.instance_eval &block
    rescue Exception => e
      puts "Playmo ERROR!"
      puts recipe.to_s
      puts e
      exit!
    end
  end
end