On 2/21/07, Adrian Howard <[EMAIL PROTECTED]> wrote:
> Rose::DB::Object::Loader->new(
>      db           => MyApp::DB->new,
>      class_prefix => 'MyApp'
> )->make_classes(
>      pre_init_hook => sub {
>          my $meta = shift;
>          $meta->column( 'some_column' )->alias( '_some_column' )
>              if $meta->table eq 'some_table';
>      }
> );
>
> then off in MyApp::SomeTable I do:
>
> sub some_column {
>      my $self = shift;
>      # ...stuff I need to do before changing value goes here...
>      return $self->_some_column( @_ );
> }
>
> Reasonable? Is there a better way (for some definition of "better")?

That's reasonable.  I've done similar things in generated and manually
created classes.

> As I understand it triggers happen after the object is updated in memory. I
> want to shim stuff in before this (so I can preserve the original value if I
> don't want the update to proceed)

You're right that the on_set trigger happens after the column value
has been set.  I could probably stand to add a few more trigger events
(e.g., before_set) but I'm wary of trigger-itis gumming up the works.
So I've just been waiting to see what kinds of events people actually
need.  It seems like you're registering one vote for before_set :)
But in the meantime, the technique you're using instead is fine.

-John

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to