mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
implement sparse fieldsets http://jsonapi.org/format/#fetching-sparse-fieldsets
This commit is contained in:
@@ -124,7 +124,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
|
||||
|
||||
Reference in New Issue
Block a user