Module: Enumerable

Defined in:
lib/mapify.rb

Instance Method Summary collapse

Instance Method Details

#hashify(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/mapify.rb', line 12

def hashify(*args)
  fail_fast?(args)

  map do |object|
    args.reduce({}) do |hash, arg|
      hash[arg] = object.public_send(arg)
      hash
    end
  end
end

#mapify(*args) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/mapify.rb', line 2

def mapify(*args)
  fail_fast?(args)

  map do |object|
    args.map do |arg|
      object.public_send(arg)
    end
  end
end