Sha256: 5a3bdcd936e9d941e5e470f95a2032fb010343287272168effeae84c693b8a76

Contents?: true

Size: 971 Bytes

Versions: 4

Compression:

Stored size: 971 Bytes

Contents

#require 'thor/actions'


module Playmo
  class Action
    cattr_accessor :actions

    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

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playmo-0.1.10 lib/playmo/action.rb
playmo-0.1.9 lib/playmo/action.rb
playmo-0.1.8 lib/playmo/action.rb
playmo-0.1.7 lib/playmo/action.rb