Module: Drum::ToHashById

Included in:
Array
Defined in:
lib/drum/utils/ext.rb

Instance Method Summary collapse

Instance Method Details

#to_h_by_idHash<Object, Object>

Initializes a hash from the array grouping by ids as keys (which are assumed to be unique).

Returns:



72
73
74
# File 'lib/drum/utils/ext.rb', line 72

def to_h_by_id
  self.map { |v| [v.id, v] }.to_h
end