lib/confuse/namespace.rb in confuse-0.1.3 vs lib/confuse/namespace.rb in confuse-0.1.4
- old
+ new
@@ -7,12 +7,12 @@
attr_reader :items, :supress_warnings_flag, :strict_flag
def initialize(&block)
@items = {}
- @supress_warnings = false
- @strict = false
+ @supress_warnings_flag = false
+ @strict_flag = false
instance_eval(&block)
end
def define(name, &block)
@items[name] = ConfigItem.new(name, &block)
@@ -56,10 +56,20 @@
end
def merge!(namespace)
@strict_flag = namespace.strict
@supress_warnings_flag = namespace.supress_warnings
- @items.merge! namespace.items
+ @items.merge! namespace.clone.items
+ end
+
+ def clone
+ c = super
+ items = @items.reduce({}) do |m, (k, v)|
+ m[k] = v.clone
+ m
+ end
+ c.instance_variable_set(:"@items", items)
+ c
end
end
end