From 98d009a000b183039feee17d7cca90572247e8aa Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Tue, 11 Aug 2015 17:04:12 -0500 Subject: [PATCH] Let FlattenJson adapter decide it doesn't include meta --- lib/active_model/serializer/adapter.rb | 2 +- lib/active_model/serializer/adapter/flatten_json.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/active_model/serializer/adapter.rb b/lib/active_model/serializer/adapter.rb index 7c0614342..0b8118d60 100644 --- a/lib/active_model/serializer/adapter.rb +++ b/lib/active_model/serializer/adapter.rb @@ -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 diff --git a/lib/active_model/serializer/adapter/flatten_json.rb b/lib/active_model/serializer/adapter/flatten_json.rb index 87b3ea8c4..7ed570349 100644 --- a/lib/active_model/serializer/adapter/flatten_json.rb +++ b/lib/active_model/serializer/adapter/flatten_json.rb @@ -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