mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
updating tests to match new adapters structure
This commit is contained in:
@@ -22,7 +22,8 @@ module ActiveModel
|
||||
|
||||
def as_json(options = {})
|
||||
hash = serializable_hash(options)
|
||||
include_meta(hash)
|
||||
include_meta(hash) unless self.class == FlattenJson
|
||||
hash
|
||||
end
|
||||
|
||||
def self.create(resource, options = {})
|
||||
|
||||
@@ -7,8 +7,6 @@ module ActiveModel
|
||||
attr_reader :meta, :meta_key
|
||||
|
||||
def initialize(objects, options = {})
|
||||
options.merge!(root: nil)
|
||||
|
||||
@objects = objects.map do |object|
|
||||
serializer_class = options.fetch(
|
||||
:serializer,
|
||||
@@ -21,7 +19,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def json_key
|
||||
@objects.first.json_key.pluralize if @objects.first
|
||||
@objects.first.json_key if @objects.first
|
||||
end
|
||||
|
||||
def root=(root)
|
||||
|
||||
@@ -12,7 +12,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def fields_for(serializer)
|
||||
key = serializer.json_key || serializer.class.root_name
|
||||
key = serializer.json_key
|
||||
fields[key.to_sym]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user