Module: NestedObjects::Mixin
- Defined in:
- lib/nested_objects/mixin.rb
Overview
Include this module to add methods for working with nested data structures
Usually included into the Object class.
Instance Method Summary collapse
-
#nested_bury(path, value) ⇒ Object
Sets a value within a nested data structure.
-
#nested_deep_copy ⇒ Object
Creates a deep copy of data using Marshal.
-
#nested_delete(path) ⇒ Object
Delete a key or element from nested data identified by path.
-
#nested_dig(path) ⇒ Object
Retrieves the value at the specified path in the given data.
-
#nested_path?(path) ⇒ Boolean
Check if the path is valid for the given data structure.
Instance Method Details
#nested_bury(path, value) ⇒ Object
Sets a value within a nested data structure
Creates intermediate Hashes along the path if they do not exist. Does NOT create intermediate Arrays (creates a Hash instead).
23 |
# File 'lib/nested_objects/mixin.rb', line 23 def nested_bury(path, value) = NestedObjects.bury(self, path, value) |
#nested_deep_copy ⇒ Object
Creates a deep copy of data using Marshal
29 |
# File 'lib/nested_objects/mixin.rb', line 29 def nested_deep_copy = NestedObjects.deep_copy(self) |
#nested_delete(path) ⇒ Object
Delete a key or element from nested data identified by path
26 |
# File 'lib/nested_objects/mixin.rb', line 26 def nested_delete(path) = NestedObjects.delete(self, path) |
#nested_dig(path) ⇒ Object
Retrieves the value at the specified path in the given data
20 |
# File 'lib/nested_objects/mixin.rb', line 20 def nested_dig(path) = NestedObjects.dig(self, path) |
#nested_path?(path) ⇒ Boolean
Check if the path is valid for the given data structure
17 |
# File 'lib/nested_objects/mixin.rb', line 17 def nested_path?(path) = NestedObjects.path?(self, path) |