Skip to content

Commit 19d8a54

Browse files
author
Robert Ross
committed
Add some code clarity since it was getting messy.
1 parent f1401eb commit 19d8a54

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/grape/entity.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ def value_for(attribute, options = {})
203203
elsif exposure_options[:using]
204204
exposure_options[:using].represent(object.send(attribute), :root => nil)
205205
elsif exposure_options[:format_with]
206-
if exposure_options[:format_with].is_a? Symbol
207-
self.send(exposure_options[:format_with].to_sym, object.send(attribute))
208-
elsif exposure_options[:format_with].respond_to? :call
209-
exposure_options[:format_with].call(object.send(attribute))
206+
format_with = exposure_options[:format_with]
207+
208+
if format_with.is_a? Symbol
209+
self.send(format_with.to_sym, object.send(attribute))
210+
elsif format_with.respond_to? :call
211+
format_with.call(object.send(attribute))
210212
end
211213
else
212214
object.send(attribute)

0 commit comments

Comments
 (0)