Dave Rolsky wrote:
> 
> On Thu, 3 Jul 2003, Flavio Soibelmann Glock wrote:
> > +    # note: the {as_ical} key is a DT::Event::ICal extension
> > +    #   to Set::Infinite
> > +    $base_set->{set}{as_ical} = [ uc('recur:'.$recur_str) ];
> 
> Please don't do this.  Just use a subclass of DateTime::Set.

Is this ok?

  DateTime::Set::ICal

I'm not happy with this solution. 
There should exist another way to add this kind of 
properties to an object.
If we could find an elegant way to fix this, 
it would be applicable to a bunch of other problems.

In this particular case, we could use something like:

  $dt_set->set_formatter( \&my_sub );

such that I'd write:

  $base_set->set_formatter( 
      sub { uc('recur:'.$recur_str) }
  );

and read it back with

  print $base_set->as_string;

Yet another API option, much more flexible:

  $base_set->set_formatter( 
      ical => sub { uc('recur:'.$recur_str) }
  );

and then use it with

  print $base_set->as_string( 'ical' );

- Flavio S. Glock

Reply via email to