Module Origin::Extensions::Hash
In: lib/origin/extensions/hash.rb

This module contains additional hash behaviour.

Methods

Public Instance methods

Add an object to a hash using the merge strategies.

@example Add an object to a hash.

  { field: value }.__add__({ field: other_value })

@param [ Hash ] object The other hash to add.

@return [ Hash ] The hash with object added.

@since 1.0.0

Merge this hash into the provided array.

@example Merge the hash into the array.

  { field: value }.__add_from_array__([ 1, 2 ])

@param [ Array ] value The array to add to.

@return [ Hash ] The merged hash.

@since 1.0.0

Make a deep copy of this hash.

@example Make a deep copy of the hash.

  { field: value }.__deep_copy__

@return [ Hash ] The copied hash.

@since 1.0.0

Get the object as expanded.

@example Get the object expanded.

  obj.__expand_complex__

@return [ Hash ] The expanded hash.

@since 1.0.5

Add an object to a hash using the merge strategies.

@example Add an object to a hash.

  { field: value }.__intersect__({ field: other_value })

@param [ Hash ] object The other hash to intersect.

@return [ Hash ] The hash with object intersected.

@since 1.0.0

Merge this hash into the provided array.

@example Merge the hash into the array.

  { field: value }.__intersect_from_array__([ 1, 2 ])

@param [ Array ] value The array to intersect to.

@return [ Hash ] The merged hash.

@since 1.0.0

Merge this hash into the provided object.

@example Merge the hash into the object.

  { field: value }.__intersect_from_object__([ 1, 2 ])

@param [ Object ] value The object to intersect to.

@return [ Hash ] The merged hash.

@since 1.0.0

Get the hash as a sort option.

@example Get the hash as a sort option.

  { field: 1 }.__sort_option__

@return [ Hash ] The hash as sort option.

@since 1.0.0

Add an object to a hash using the merge strategies.

@example Add an object to a hash.

  { field: value }.__union__({ field: other_value })

@param [ Hash ] object The other hash to union.

@return [ Hash ] The hash with object unioned.

@since 1.0.0

Merge this hash into the provided object.

@example Merge the hash into the object.

  { field: value }.__union_from_object__([ 1, 2 ])

@param [ Object ] value The object to union to.

@return [ Hash ] The merged hash.

@since 1.0.0

Update all the values in the hash with the provided block.

@example Update the values in place.

  { field: "1" }.update_values(&:to_i)

@param [ Proc ] block The block to execute on each value.

@return [ Hash ] the hash.

@since 1.0.0

[Validate]