lib/hashr.rb in hashr-0.0.9 vs lib/hashr.rb in hashr-0.0.10
- old
+ new
@@ -15,11 +15,12 @@
def definition
@definition ||= {}
end
end
- def initialize(data = {}, definition = self.class.definition)
+ def initialize(data = {}, definition = self.class.definition, &block)
replace(deep_hashrize(definition.deep_merge((data || {}).deep_symbolize_keys)))
+ (class << self; self; end).class_eval(&block) if block_given?
end
def []=(key, value)
super(key, value.is_a?(Hash) ? self.class.new(value, {}) : value)
end