Module: Interfacets::Client::Utils::MrubyPatches::ArrayPatch

Defined in:
lib/interfacets/client/utils/mruby_patches.rb

Instance Method Summary collapse

Instance Method Details

#index_by ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
# File 'lib/interfacets/client/utils/mruby_patches.rb', line 30

def index_by
  raise(ArgumentError) unless block_given?

  result = {}
  each { |elem| result[yield(elem)] = elem }
  result
end