class ActiveResource::InheritingHash
Public Class Methods
Source
# 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
Calls superclass method
Public Instance Methods
Source
# File lib/active_resource/inheriting_hash.rb, line 11 def [](key) super || @parent_hash[key] end
Calls superclass method
Source
# File lib/active_resource/inheriting_hash.rb, line 26 def inspect to_hash.inspect end
Source
# File lib/active_resource/inheriting_hash.rb, line 22 def pretty_print(pp) pp.pp_hash to_hash end
So we can see the merged object in IRB or the Rails console
Source
# File lib/active_resource/inheriting_hash.rb, line 17 def to_hash @parent_hash.to_hash.merge(self) end
Merges the flattened parent hash (if it’s an InheritingHash) with ourself