Skip to content

Instantly share code, notes, and snippets.

@lis2
Created July 3, 2014 01:52
Show Gist options
  • Save lis2/79c910306c74410cc8cb to your computer and use it in GitHub Desktop.
Save lis2/79c910306c74410cc8cb to your computer and use it in GitHub Desktop.
results = [
{:title => 'Anchor date:', :result => field_or_not_available(@selected_band, :anchor_on, :to_au)},
{:title => 'Run on date:', :result => field_or_not_available(@selected_band, :run_on, :to_au)},
{:title => 'End on date:', :result => field_or_not_available(@selected_band, :end_on, :to_au)},
{:title => 'Status:', :result => field_or_not_available(@selected_band, :status)}
]
def field_or_not_available(object, *methods)
methods.inject(object) {|o, a| o.send(:try, a); o } || "N/A"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment