Skip to content

Commit

Permalink
Rubocop changes + Gem bump
Browse files Browse the repository at this point in the history
  • Loading branch information
grdw committed Apr 12, 2019
1 parent cf7b5d7 commit c6017d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
seri (1.0.0)
seri (1.0.1)
appsignal (~> 2.7)
oj (~> 3.7)

Expand Down
12 changes: 5 additions & 7 deletions lib/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ def serialize_value(attribute)
value = extract_value(attribute)
serializer = attribute.serializer

if serializer
if ARRAYS.any? { |match| value.class.to_s.end_with?(match) }
value.map { |v| serializer.new(v).to_h }
else
serializer.new(value).to_h
end
return value unless serializer

if ARRAYS.any? { |match| value.class.to_s.end_with?(match) }
value.map { |v| serializer.new(v).to_h }
else
value
serializer.new(value).to_h
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class OneToOneCarSerializerWithItems < Serializer
attribute :items

def items
%w(1 2 3)
%w[1 2 3]
end
end

Expand All @@ -102,7 +102,7 @@ def items
serialized = car_serializer.to_h

expect(serialized.fetch(:mileage)).to eq(25)
expect(serialized.fetch(:items)).to eq(%w(1 2 3))
expect(serialized.fetch(:items)).to eq(%w[1 2 3])
end
end

Expand Down

0 comments on commit c6017d4

Please sign in to comment.