Created
June 14, 2013 14:04
-
-
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..
This file contains 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
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