Merge pull request #700 from arenoir/sparse_fieldsets

sparse fieldsets
This commit is contained in:
Alexandre de Oliveira
2015-01-06 09:38:51 -02:00
10 changed files with 131 additions and 5 deletions

View File

@@ -132,7 +132,14 @@ module ActiveModel
end
def attributes(options = {})
self.class._attributes.dup.each_with_object({}) do |name, hash|
attributes =
if options[:fields]
self.class._attributes & options[:fields]
else
self.class._attributes.dup
end
attributes.each_with_object({}) do |name, hash|
hash[name] = send(name)
end
end