Tuesday, June 22, 2010

quarter_time 0.3.1 released

A small but useful addition to the quarter_time gem I released a couple weeks ago. Normally the scope added to models that include the QuarterTime::QuarterDriven module would be used with other Quarter objects:

class SomeModel < ActiveRecord::Base
  include QuarterTime::QuarterDriven
end

q = Quarter.new(2010,2)
model = SomeModel.for_quarter(q).first
However, in cases where I didn't already have a quarter object built or coming from another model, it seemed like overkill to build the object just to pass a couple parameters. So, here's an additional (equivalent) syntax you can use to select models by quarter:
class SomeModel < ActiveRecord::Base
  include QuarterTime::QuarterDriven
end

model = SomeModel.for_quarter(2010,2)

No comments: