S.E.A.N.I.C.U.S.

Tuesday, June 06, 2006

Major FlexTimes update/refactor

Prompted by a bug submitted to the project last night, I've decided to add some major stuff to FlexTimes:

  1. Many options that are normally passed through to the non-instance helpers (select_xxx) were not being passed, so I'm modifying datetime_select to cleanse the options hash and then pass it on to each helper. One example is :start_year. Unfortunately, because of the way the hash parameters will be parsed, I don't think I'll allow :include_blank.

  2. The most common error in using FlexTimes was not having a datetime_column declaration (or one of its sister declarations) in the model. I've decided to alleviate this by overriding ActiveRecord's write_attribute method, rather than futzing with multiparameter attributes. Spawned from this effort were some other refactorings:

    • Hash will receive two new methods: to_date, and to_time. It only makes sense, since much of what is done in the AR helpers is converting between a hash and a date or time.

    • Likewise, Date and Time will receive a to_hash method. QED.


Not that I have any illusions, but if FlexTimes were to be included in the core, this is the path it must take -- DRY and multi-purpose integration.

For compatibility, the old AR methods will not go away. I'll be posting this newest update as version 1.5 (tarball). I anticipate version 2.0 will do away with the AR declarations.