Created
July 3, 2014 02:06
Revisions
-
lis2 created this gist
Jul 3, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ {: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