Rename FlattenJson to Attributes (allow plural adapter names)

This commit is contained in:
Benjamin Fleischer
2015-09-04 04:22:10 -05:00
parent ceef214f1e
commit c6f8d0f5f2
15 changed files with 36 additions and 35 deletions

View File

@@ -1,8 +1,8 @@
class ActiveModel::Serializer::Adapter::FlattenJson < ActiveModel::Serializer::Adapter::Json
class ActiveModel::Serializer::Adapter::Attributes < ActiveModel::Serializer::Adapter
def serializable_hash(options = nil)
options ||= {}
if serializer.respond_to?(:each)
result = serializer.map { |s| FlattenJson.new(s).serializable_hash(options) }
result = serializer.map { |s| Attributes.new(s).serializable_hash(options) }
else
hash = {}
@@ -43,7 +43,7 @@ class ActiveModel::Serializer::Adapter::FlattenJson < ActiveModel::Serializer::A
private
# no-op: FlattenJson adapter does not include meta data, because it does not support root.
# no-op: Attributes adapter does not include meta data, because it does not support root.
def include_meta(json)
json
end

View File

@@ -4,7 +4,7 @@ class ActiveModel::Serializer::Adapter::Json < ActiveModel::Serializer::Adapter
def serializable_hash(options = nil)
options ||= {}
{ root => FlattenJson.new(serializer).serializable_hash(options) }
{ root => Attributes.new(serializer).serializable_hash(options) }
end
private