Sha256: f448b6440f41b10c1997304ea84edfba30b15923445e28081f687487977c27a4

Contents?: true

Size: 662 Bytes

Versions: 3

Compression:

Stored size: 662 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?(path)
      Namespace.root.executed_plans << path
      @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

3 entries across 3 versions & 1 rubygems

Version Path
blueprints-0.3.4 lib/blueprints/plan.rb
blueprints-0.3.3 lib/blueprints/plan.rb
blueprints-0.3.2 lib/blueprints/plan.rb