Sha256: 7ccc3f24f8381b38ebe911e2abbc7e71f95fa1db884c6eeff5b9dc6811b5011a

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Blueprints
  class RootNamespace < Namespace
    attr_reader :context, :plans
    attr_accessor :executed_plans
    
    def initialize
      @executed_plans = Set.new
      @global_executed_plans = Set.new
      @global_context = Module.new

      super ''
    end

    def setup
      @context = YAML.load(@global_context)
      @executed_plans = @global_executed_plans.clone
    end

    def copy_ivars(to)
      @context.instance_variables.each do |iv|
        to.instance_variable_set(iv, @context.instance_variable_get(iv))
      end
    end

    def prebuild(plans)
      @context = @global_context
      @global_scenarios = build(plans) if plans
      @global_executed_plans = @executed_plans
      @global_context = YAML.dump(@global_context)
    end

    def build(*names)
      names.map {|name| self[name].build}
    end

    def add_variable(name, value)
      name = "@#{name}" unless name.to_s[0, 1] == "@" 
      @context.instance_variable_set(name, value) unless @context.instance_variable_get(name)
    end

    @@root = RootNamespace.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blueprints-0.3.1 lib/blueprints/root_namespace.rb
blueprints-0.3.0 lib/blueprints/root_namespace.rb