Skip to content

Commit

Permalink
Merge pull request #1048 from bf4/cleanup_meta_in_adapter
Browse files Browse the repository at this point in the history
Let FlattenJson adapter decide it doesn't include meta
  • Loading branch information
joaomdmoura committed Aug 18, 2015
2 parents e7d3323 + 98d009a commit e384b65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_model/serializer/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def serializable_hash(options = nil)

def as_json(options = nil)
hash = serializable_hash(options)
include_meta(hash) unless self.class == FlattenJson
include_meta(hash)
hash
end

Expand Down
7 changes: 7 additions & 0 deletions lib/active_model/serializer/adapter/flatten_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ def serializable_hash(options = {})
super
@result
end

private

# no-op: FlattenJson adapter does not include meta data, because it does not support root.
def include_meta(json)
json
end
end
end
end
Expand Down

0 comments on commit e384b65

Please sign in to comment.