Method: ReferenceBook::Library.hash_for

Defined in:
lib/reference_book/library.rb

.hash_for(attribute) ⇒ Object Also known as: hash_pluck



68
69
70
71
72
73
74
# File 'lib/reference_book/library.rb', line 68

def hash_for(attribute)
  Hash[
    shelf.map do |key, book|
      [key, (book[attribute] if book.respond_to?(attribute))]
    end
  ]
end