Move id and json_api_type methods from Serializer to JsonApi.

This commit is contained in:
Lucas Hosseini
2015-08-31 02:32:38 +02:00
parent 64168cbecd
commit 8482abfac7
3 changed files with 22 additions and 30 deletions

View File

@@ -146,18 +146,6 @@ module ActiveModel
@root || object.class.model_name.to_s.underscore
end
def id
object.id if object
end
def json_api_type
if config.jsonapi_resource_type == :plural
object.class.model_name.plural
else
object.class.model_name.singular
end
end
def attributes(options = {})
attributes =
if options[:fields]
@@ -166,8 +154,6 @@ module ActiveModel
self.class._attributes.dup
end
attributes += options[:required_fields] if options[:required_fields]
attributes.each_with_object({}) do |name, hash|
unless self.class._fragmented
hash[name] = send(name)