Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison

[prev] [thread] [next] [Date index for 2005/04/22]

From: Carl Johnstone
Subject: Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison
Date: 11:53 on 22 Apr 2005
(Sending the reply back to the list as there are people who are much smarter 
than me on there! :-)

>> Would an alternative to call update on the object within DESTROY? 
>> (There's currently a croak in there to warn that you haven't called 
>> update)
>
> Personaly, I would very much like an option to have an object update on 
> destroy. Maybe indicated the
> same way autoupdate is done.

If you want this to happen for all instances of a particular class, than all 
you need is this:

sub DESTROY {
  my $self = shift;
  $self->update if scalar($self->is_changed);
  $self->SUPER::DESTROY;
}

Obviously if you want all your classes to behave in this was you can put it 
in your base class.

Carl

Re: Hibernate and ActiveRecord (Ruby-on-Rails) comparison
Carl Johnstone 11:53 on 22 Apr 2005

Generated at 09:29 on 27 Apr 2005 by mariachi v0.52