0.0
No commit activity in last 3 years
No release in over 3 years
Provides getters/setters for when datetimes should also act like booleans
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Truthy Date

Provides super simple getter/setters for datetimes that should also act as booleans.

Usage:

class Coffee < ActiveRecord::Base
  extend TruthyDate
  truthy_date :ordered_at,  :as => :ordered
  truthy_date :consumed_at, :as => :empty
end

Which lets you do things like:

> coffee.ordered = true
true

> coffee.ordered?
true

> coffee.consumed = true
true

> coffee.empty?
true

> coffee.consumed_at
Thu, 06 Feb 2014 17:39:48 UTC +00:00

> coffee.ordered_at
Thu, 06 Feb 2014 17:39:40 UTC +00:00

> coffee.consumed = false
false

> coffee.empty?
false

> coffee.consumed_at
nil

The non "?" getter method is also defined in order to play well with the form builders out there:

> coffee.empty
false