class ActiveResource::InheritingHash
Public Class Methods
new(parent_hash = {})
click to toggle source
Calls superclass method
# File lib/active_resource/inheriting_hash.rb, line 5 def initialize(parent_hash = {}) # Default hash value must be nil, which allows fallback lookup on parent hash super(nil) @parent_hash = parent_hash end
Public Instance Methods
[](key)
click to toggle source
Calls superclass method
# File lib/active_resource/inheriting_hash.rb, line 11 def [](key) super || @parent_hash[key] end
inspect()
click to toggle source
# File lib/active_resource/inheriting_hash.rb, line 26 def inspect to_hash.inspect end
pretty_print(pp)
click to toggle source
So we can see the merged object in IRB or the Rails console
# File lib/active_resource/inheriting_hash.rb, line 22 def pretty_print(pp) pp.pp_hash to_hash end
to_hash()
click to toggle source
Merges the flattened parent hash (if it’s an InheritingHash
) with ourself
# File lib/active_resource/inheriting_hash.rb, line 17 def to_hash @parent_hash.to_hash.merge(self) end
to_s()
click to toggle source
# File lib/active_resource/inheriting_hash.rb, line 30 def to_s inspect end