module Drum::ToHashById

Public Instance Methods

to_h_by_id() click to toggle source

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

@return [Hash<Object, Object>] The resulting hash

# File lib/drum/utils/ext.rb, line 72
def to_h_by_id
  self.map { |v| [v.id, v] }.to_h
end