Created
July 3, 2014 02:06
-
-
Save lis2/fcf2dde239fc13ab603b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:title => 'Anchor date:', :result => fields_to_na(try_chain(@selected_band, :anchor_on, :to_au))} | |
def fields_to_na(data) | |
return 'N/A' if data.blank? | |
return yield(data) if block_given? | |
data | |
end | |
def try_chain(object, *methods) | |
methods.inject(object) {|o, a| o.send(:try, a) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment