Created
July 3, 2014 02:10
-
-
Save lis2/916c1ef78f1e56c2c8f4 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