Skip to content

Instantly share code, notes, and snippets.

@ryangreenberg
Created March 26, 2012 23:03
Show Gist options
  • Save ryangreenberg/2210448 to your computer and use it in GitHub Desktop.
Save ryangreenberg/2210448 to your computer and use it in GitHub Desktop.
todo_for_real
require 'date'
class ExpiredTodoError < StandardError; end
# Implementation #
def todo(what, by_date)
if production? || (Date.parse(by_date) >= Date.today)
yield
else
raise ExpiredTodoError, "TODO: #{what}"
end
end
# Would actually be Rails.env.production? or something similar #
def production?
false
end
# Sample usage #
todo("Make this code less janky", "4/1/2012") do
o = Object.new
Marshal.load(Marshal.dump(o))
end
@reinh
Copy link

reinh commented Mar 26, 2012

Production guard seems unnecessary.

@davelnewton
Copy link

todo("Make this code less janky", Chronic.parse('next Tuesday')) do
#foo
end

See, this is what happens when someone has an idea.

@markburns
Copy link

slight alteration to the to_do_or_else would be:

to_do_or_die

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment