lib/hash.rb in hash_dot-2.4.2 vs lib/hash.rb in hash_dot-2.5.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + class Hash class << self attr_accessor :use_dot_syntax attr_accessor :hash_dot_use_default end @@ -14,11 +16,11 @@ end def method_missing(method, *args) return super(method, *args) unless to_dot? - method, chain = method.to_s.split('.', 2).map(&:to_sym) + method, chain = method.to_s.split(".", 2).map(&:to_sym) return send(method).send(chain, *args) if chain prop = create_prop(method) @@ -29,14 +31,16 @@ else super(method, args) end end - def respond_to?(method, include_all=false) + def respond_to?(method, include_all = false) return super(method, include_all) unless to_dot? + prop = create_prop(method) return true if key?(prop) + super(method, include_all) end private @@ -46,10 +50,10 @@ obj.each do |el| dotify_obj(el, use_default: use_default) end when Hash dotify_hash(obj, use_default: use_default) - # else no-op + # else no-op end end def dotify_hash(hash, use_default: false) hash.use_dot_syntax = true