Sha256: 767c5c1ae29575294c23bd4e5ffe939de4866a30f63488fe1f731696101762fd

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module AssemblyLine
  module GlobalContext
    extend self

    def let(name, &block)
      define_method name do
        let_values[name] ||= instance_eval(&block)
      end
      ::Kernel.def_delegator :assembly_line_global_context, name
    end

    # there are no tests so just run the block
    def before(scope=:each, &block)
      instance_eval &block
    end

    def clear
      instance_variables.each do |name|
        instance_variable_set(name, nil)
      end
    end

    protected

    def let_values
      @let_values ||= {}
    end

    attr_writer :context
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assembly_line-0.2.0 lib/assembly_line/global_context.rb