Sha256: e1895d05152a5bdedad5348316514292332576a2f1a6a20bb08e555186ecc4d5

Contents?: true

Size: 1.05 KB

Versions: 3

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

3 entries across 3 versions & 1 rubygems

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