Sha256: b82e70494f7af04b8b0aded7c0b22accb9c49f7a5209e2cbc4fc6390bd40fdb2

Contents?: true

Size: 544 Bytes

Versions: 1

Compression:

Stored size: 544 Bytes

Contents

module Egi
  class Env
    def initialize(name)
      @name = name
    end

    def merge!(other)
      other = (other.is_a?(Env) ? other.items : other)
      # because items has default proc and cannnot dump
      items.merge!(Marshal.load(Marshal.dump(Hash[other])))
    end

    def items
      @items ||= Hash.new {|hash, key| hash[key] = { :name => key } }
    end

    def item(name, hash)
      items[name.to_sym].merge!(hash)
    end

    def method_missing(name, *args)
      items.has_key?(name) ? items[name] : nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
egi-0.0.1 lib/egi/env.rb