Sha256: 37bce40f84da888c6e8c3b945bee1f85107ae945aa8d24801481039c29b8dd46
Contents?: true
Size: 680 Bytes
Versions: 1
Compression:
Stored size: 680 Bytes
Contents
module Egi class Env def initialize(name) @name = name @default = {} end def set(default = {}) @default = default 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 group(name = nil, &block) items.merge!(Class.new(Group).new(name).instance_eval(&block).items) end def items @items ||= Hash.new {|hash, key| hash[key] = Item[{ :name => key }.merge(@default)] } end def item(name, hash = {}) items[name.to_sym].update(hash) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
egi-0.0.3 | lib/egi/env.rb |