Sha256: ad481d8391292e3512d9c641c4625593428bdd98fa07d8861a30efa29ecbdea4

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

module Blueprints
  class Plan < Buildable
    def initialize(name, &block)
      super(name)
      @block = block
    end

    def build_plan
      surface_errors do
        if @block
          @result = Namespace.root.context.module_eval(&@block)
          Namespace.root.add_variable(path, @result)
        end
      end unless Namespace.root.executed_plans.include?(@name)
      Namespace.root.executed_plans << @name
      @result
    end

    private

    def surface_errors
      yield
    rescue StandardError => error
      puts "\n=> There was an error building scenario '#{@name}'", error.inspect, '', error.backtrace
      raise error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blueprints-0.3.1 lib/blueprints/plan.rb