Skip to content

Commit

Permalink
Add some code clarity since it was getting messy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Ross committed Mar 31, 2012
1 parent f1401eb commit 19d8a54
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/grape/entity.rb
Expand Up @@ -203,10 +203,12 @@ def value_for(attribute, options = {})
elsif exposure_options[:using]
exposure_options[:using].represent(object.send(attribute), :root => nil)
elsif exposure_options[:format_with]
if exposure_options[:format_with].is_a? Symbol
self.send(exposure_options[:format_with].to_sym, object.send(attribute))
elsif exposure_options[:format_with].respond_to? :call
exposure_options[:format_with].call(object.send(attribute))
format_with = exposure_options[:format_with]

if format_with.is_a? Symbol
self.send(format_with.to_sym, object.send(attribute))
elsif format_with.respond_to? :call
format_with.call(object.send(attribute))
end
else
object.send(attribute)
Expand Down

0 comments on commit 19d8a54

Please sign in to comment.