mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
updating adapters to follow new root logic
This commit is contained in:
parent
a0753cb0bc
commit
2bf91a0c0e
@ -1,5 +1,3 @@
|
|||||||
require 'active_model/serializer/adapter/json/fragment_cache'
|
|
||||||
|
|
||||||
module ActiveModel
|
module ActiveModel
|
||||||
class Serializer
|
class Serializer
|
||||||
class Adapter
|
class Adapter
|
||||||
|
|||||||
@ -6,7 +6,6 @@ module ActiveModel
|
|||||||
class JsonApi < Adapter
|
class JsonApi < Adapter
|
||||||
def initialize(serializer, options = {})
|
def initialize(serializer, options = {})
|
||||||
super
|
super
|
||||||
serializer.root = true
|
|
||||||
@hash = { data: [] }
|
@hash = { data: [] }
|
||||||
|
|
||||||
if fields = options.delete(:fields)
|
if fields = options.delete(:fields)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def json_key
|
def json_key
|
||||||
@objects.first.json_key if @objects.first
|
@objects.first.json_key.pluralize if @objects.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def root=(root)
|
def root=(root)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user