Skip to content

Instantly share code, notes, and snippets.

@kcurtin
Created June 14, 2013 14:04
Show Gist options
  • Save kcurtin/5782049 to your computer and use it in GitHub Desktop.
Save kcurtin/5782049 to your computer and use it in GitHub Desktop.
Finally found a good way to set up default values for a Struct..
require 'date'
DateRange = Struct.new(:start_date, :end_date) do
def start_date
self[:start_date] || Date.today - 30
end
def end_date
self[:end_date] || Date.today
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment