Class: InheritableAccessors::InheritableHash
- Inherits:
-
Object
- Object
- InheritableAccessors::InheritableHash
- Extended by:
- Forwardable
- Defined in:
- lib/inheritable_accessors/inheritable_hash.rb
Constant Summary collapse
- WRITE_METHODS =
%w{ []= initialize merge! store }
- READ_METHODS =
%w{ == [] each each_pair each_value empty? eql? fetch flatten has_key? has_value? hash include? index inspect invert key key? keys length member? merge pretty_print rehash select size to_a to_h to_s value? values }
Instance Attribute Summary collapse
-
#__local_values__ ⇒ Object
Returns the value of attribute local_values.
-
#__parent__ ⇒ Object
readonly
Returns the value of attribute __parent__.
Instance Method Summary collapse
- #inherit_copy ⇒ Object (also: #initialize_copy)
-
#initialize(prototype = nil) ⇒ InheritableHash
constructor
A new instance of InheritableHash.
- #to_hash ⇒ Object
Constructor Details
#initialize(prototype = nil) ⇒ InheritableHash
Returns a new instance of InheritableHash.
22 23 24 25 |
# File 'lib/inheritable_accessors/inheritable_hash.rb', line 22 def initialize(prototype=nil) @__local_values__ = Hash.new @__parent__ = prototype end |
Instance Attribute Details
#__local_values__ ⇒ Object
Returns the value of attribute local_values.
5 6 7 |
# File 'lib/inheritable_accessors/inheritable_hash.rb', line 5 def __local_values__ @__local_values__ end |
#__parent__ ⇒ Object (readonly)
Returns the value of attribute __parent__.
6 7 8 |
# File 'lib/inheritable_accessors/inheritable_hash.rb', line 6 def __parent__ @__parent__ end |
Instance Method Details
#inherit_copy ⇒ Object Also known as: initialize_copy
35 36 37 |
# File 'lib/inheritable_accessors/inheritable_hash.rb', line 35 def inherit_copy InheritableHash.new(self) end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/inheritable_accessors/inheritable_hash.rb', line 27 def to_hash if !!__parent__ __parent__.to_hash.merge(__local_values__) else __local_values__.clone end end |