mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Move id and json_api_type methods from Serializer to JsonApi.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user