Compute only requested attributes.

This commit is contained in:
Lucas Hosseini
2015-10-31 19:20:53 +01:00
parent ecc3b35517
commit 0948c4199a
3 changed files with 5 additions and 10 deletions

View File

@@ -238,10 +238,9 @@ module ActiveModel
# Return the +attributes+ of +object+ as presented
# by the serializer.
def attributes
attributes = self.class._attributes.dup
attributes.each_with_object({}) do |name, hash|
def attributes(requested_attrs = nil)
self.class._attributes.each_with_object({}) do |name, hash|
next unless requested_attrs.nil? || requested_attrs.include?(name)
if self.class._fragmented
hash[name] = self.class._fragmented.public_send(name)
else