Recent News

RoR: Schedulable

What it is.

If you have data that must go live on a specific date; If you have a model object you would like to query for it’s published state; If you would like the functions of publishing and un-publishing content to be precise and understandable, the Schedulable plugin may be for you. In short, adding Schedulable to your models will allow you to manage the publishing of your data through the liberal use of semantic sugar. The goal of the Schedulable plugin is to be intuitive, concise and easy while solving an often necessary and crucial business need: Scheduling your content.

How it works.

Calling schedulable automatically hooks a few methods to a published_at column:

  • scheduled? (true if the item is scheduled to be published but isn’t yet)
  • published? (true if the item is published)

The real power is when expiration is a question

schedulable :end => :archived_at

or

schedulable :published_at, :archived_at

does a little more:

  • scheduled? :archived_at (true if archived_at is set in the future)
  • archived? (true if the item has been archived)

with a note:

  • published? returns false when archived? returns true.

It’s all semantic sugar:

schedulable :activated_at, :terminated_at, :end_required => true

therefore creates:

  • activated?
  • terminated?

And that last option? It just adds a validation requiring the end to be set if the start is.

We have your other validations taken care of, too. We’re just more comfortable with things when they’re chronological.

How can I get it

On Edge:

$ script/plugin install git://github.com/cementhorses/schedulable.git

…otherwise

$ git clone git@github.com:cementhorses/schedulable.git vendor/plugins/schedulable

Comments