lib/hashr.rb in hashr-0.0.22 vs lib/hashr.rb in hashr-1.0.0

- old
+ new

@@ -36,10 +36,11 @@ end undef :id if method_defined?(:id) # undefine deprecated method #id on 1.8.x def initialize(data = {}, definition = self.class.definition, &block) + raise(ArgumentError.new("Invalid input #{data.inspect}")) unless data.nil? || data.is_a?(Hash) replace((deep_hashrize(definition.deep_merge((data || {}).deep_symbolize_keys)))) deep_defaultize(self) (class << self; self; end).class_eval(&block) if block_given? end @@ -55,11 +56,15 @@ def set(path, value, stack = []) tokens = path.to_s.split('.') tokens.size == 1 ? self[path] = value : self[tokens.shift, Hashr.new].set(tokens.join('.'), value, stack) end - def respond_to?(*args) - true + def respond_to?(method) + if self.class.raise_missing_keys + key?(method) + else + true + end end def method_missing(name, *args, &block) case name.to_s[-1, 1] when '?'