Class: Grape::Util::BaseInheritable
- Inherits:
-
Object
- Object
- Grape::Util::BaseInheritable
- Defined in:
- lib/grape/util/base_inheritable.rb
Overview
Base for classes which need to operate with own values kept in the hash and inherited values kept in a Hash-like object.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#inherited_values ⇒ Object
Returns the value of attribute inherited_values.
-
#new_values ⇒ Object
Returns the value of attribute new_values.
Instance Method Summary collapse
- #delete(key) ⇒ Object
-
#initialize(inherited_values = {}) ⇒ BaseInheritable
constructor
A new instance of BaseInheritable.
- #initialize_copy(other) ⇒ Object
- #keys ⇒ Object
Constructor Details
#initialize(inherited_values = {}) ⇒ BaseInheritable
Returns a new instance of BaseInheritable.
11 12 13 14 |
# File 'lib/grape/util/base_inheritable.rb', line 11 def initialize(inherited_values = {}) @inherited_values = inherited_values @new_values = {} end |
Instance Attribute Details
#inherited_values ⇒ Object
Returns the value of attribute inherited_values.
6 7 8 |
# File 'lib/grape/util/base_inheritable.rb', line 6 def inherited_values @inherited_values end |
#new_values ⇒ Object
Returns the value of attribute new_values.
7 8 9 |
# File 'lib/grape/util/base_inheritable.rb', line 7 def new_values @new_values end |
Instance Method Details
#delete(key) ⇒ Object
16 17 18 |
# File 'lib/grape/util/base_inheritable.rb', line 16 def delete(key) new_values.delete key end |
#initialize_copy(other) ⇒ Object
20 21 22 23 24 |
# File 'lib/grape/util/base_inheritable.rb', line 20 def initialize_copy(other) super self.inherited_values = other.inherited_values self.new_values = other.new_values.dup end |
#keys ⇒ Object
26 27 28 29 30 31 |
# File 'lib/grape/util/base_inheritable.rb', line 26 def keys combined = inherited_values.keys combined.concat(new_values.keys) combined.uniq! combined end |