Skip to content

Commit

Permalink
cut :attributes_map object allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
subvertallchris committed Apr 9, 2015
1 parent 35389b2 commit 33b4c7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/active_attr/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ def attribute=(name, value)
#
# @since 0.7.0
def attributes_map
Hash[ self.class.attribute_names.map { |name| [name, yield(name)] } ]
{}.tap do |attributes_hash|
self.class.attribute_names.each do |k|
attributes_hash[k] = yield(k)
end
end
end

module ClassMethods
Expand Down

0 comments on commit 33b4c7e

Please sign in to comment.