Method: NestedObjects::Mixin#nested_delete

Defined in:
lib/nested_objects/mixin.rb

#nested_delete(path) ⇒ Object

Delete a key or element from nested data identified by path

Examples:

data = { 'a' => { 'b' => [1, 2, 3] } }
NestedObjects.delete(data, ['a', 'b', '0']) #=> 1
data #=> { 'a' => { 'b' => [2, 3] } }

Parameters:

  • data (Hash, Array, Object)

    The structure to modify

  • path (Array<String>)

    An array of keys/indices representing the path to the item to delete

Returns:

  • (Object)

    The value of the element that was deleted

Raises:

  • (BadPathError)

    if the path is invalid or the item does not exist



26
# File 'lib/nested_objects/mixin.rb', line 26

def nested_delete(path) = NestedObjects.delete(self, path)