lib/egi/env.rb in egi-0.0.1 vs lib/egi/env.rb in egi-0.0.2
- old
+ new
@@ -8,18 +8,18 @@
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 } }
+ def group(name = nil, &block)
+ items.merge!(Class.new(Group).new(name).instance_eval(&block).items)
end
- def item(name, hash)
- items[name.to_sym].merge!(hash)
+ def items
+ @items ||= Hash.new {|hash, key| hash[key] = Item[:name => key] }
end
- def method_missing(name, *args)
- items.has_key?(name) ? items[name] : nil
+ def item(name, hash)
+ items[name.to_sym].update(hash)
end
end
end