I'm a J2EE developer by day and I'm moonlighting to migrate my
church's website to a Rails application.
One of the fundamental abstractions that any organization needs to
track is events. Events could be work schedules, pay cycles, meetings
and so forth. Events recur, of course. I would like to brainstorm with
you about possible solutions.
So on that note, I started to think about how to develop an events
feature set for a Rails application. Some of constraints I have is
that since this is fundamental to my organization's process, we need
to save Events with ActiveRecord into our database. (So I doubt Google
Calendar would work but I could be convinced otherwise). Events at
least have a title, description, start time and end time. But they
also recur. Here's where I get puzzled.
a) First solution: browse through the Outlook API (via MSDN) and
reconstruct the classes that make up RecurrenceType and
RecurrencePattern. RecurencePattern has child classes such as
RecursMonthly, RecursDaily, and RecursMonthlyNth. It seems like the
right kinds of abstraction for a helper class or a module. Perhaps it
isn't Rubyesque but refactoring can fix that problem.
The more important thing that bothers me about this set of classes is
that it doesn't seem appropriate to make them ActiveRecord classes.
It's just too busy with nouns, because subtypes of RecurrencePatterns
are manifold. I personally might have to support a RecurrencePattern
for every other Easter! Still an event has to be persisted with some
sort of recurrence pattern.
b) Next solution: I'm wondering if it would be appropriate to use a
RecurrencePattern hierarchy as a wrapper around the cron expression.
Cron expressions would be persisted to the database. If an Event has a
cron expression, we need to be able interpret the expression with
intermediate classes so that a user can set the recurrence properties
of the cron expression. The intermediate classes need to mediate in
both directions between the UI (a la Outlook's API) and the database
Like any lazy programmer, I thought there might be a plugin or gem
available. A quick search this morning turns up inactive Ruby gems to
do cron expressions. A search on plugins turns up little. Does anyone
know if any resource that could be reused?
So I might have to do it myself. Writing the classes would take a lot
of work but seems worthwhile. So worthwhile I wonder about mixing them
in to Date or Time a la ActiveSupport. Has anyone attempted to do