Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/core_ext/array.rb

Overview

Extensions to Ruby's Array class for SpecForge functionality

Adds utility methods used throughout SpecForge for array manipulation and data processing.

Direct Known Subclasses

SpecForge::Attribute::ResolvableArray

Instance Method Summary collapse

Instance Method Details

#to_merged_hHash

Merges an array of hashes into a single hash

Performs a deep merge on each hash in the array, combining them into a single hash with all keys and values.

Examples:

Merging an array of hashes

[{a: 1}, {b: 2}, {a: 3}].to_merged_h
# => {a: 3, b: 2}

Returns:

  • (Hash)

    A hash containing the merged contents of all hashes in the array



22
23
24
25
26
# File 'lib/spec_forge/core_ext/array.rb', line 22

def to_merged_h
  each_with_object({}) do |hash, output|
    output.deep_merge!(hash)
  end
end