Skip to content

Commit a9d07cd

Browse files
committed
Get rid of unnecessary instance variables, and implied dependencies.
1 parent c03427d commit a9d07cd

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/active_model/serializer/adapter/flatten_json.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ class Serializer
33
class Adapter
44
class FlattenJson < Json
55
def serializable_hash(options = {})
6-
super
7-
@result
6+
super.each_value.first
87
end
98

109
private

lib/active_model/serializer/adapter/json.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ class Json < Adapter
77
def serializable_hash(options = nil)
88
options ||= {}
99
if serializer.respond_to?(:each)
10-
@result = serializer.map { |s| FlattenJson.new(s).serializable_hash(options) }
10+
result = serializer.map { |s| FlattenJson.new(s).serializable_hash(options) }
1111
else
12-
@hash = {}
12+
hash = {}
1313

14-
@core = cache_check(serializer) do
14+
core = cache_check(serializer) do
1515
serializer.attributes(options)
1616
end
1717

@@ -21,13 +21,13 @@ def serializable_hash(options = nil)
2121

2222
if serializer.respond_to?(:each)
2323
array_serializer = serializer
24-
@hash[association.key] = array_serializer.map do |item|
24+
hash[association.key] = array_serializer.map do |item|
2525
cache_check(item) do
2626
item.attributes(opts)
2727
end
2828
end
2929
else
30-
@hash[association.key] =
30+
hash[association.key] =
3131
if serializer && serializer.object
3232
cache_check(serializer) do
3333
serializer.attributes(options)
@@ -37,10 +37,10 @@ def serializable_hash(options = nil)
3737
end
3838
end
3939
end
40-
@result = @core.merge @hash
40+
result = core.merge hash
4141
end
4242

43-
{ root => @result }
43+
{ root => result }
4444
end
4545

4646
def fragment_cache(cached_hash, non_cached_hash)

0 commit comments

Comments
 (0)