On 10/1/06 10:32 AM, Randal L. Schwartz wrote:
> it doesn't permit my userland code to set a forced value for 'modified' (since
> the code here is always setting it). I was trying to think through a solution
> to that and didn't come up with one.
One way to do that would be to add an on_set trigger to the last_modified
column and set a flag attribute within it. Then check that flag before
setting the last_modified value during the save. You'll probably need to
reset the flag on load too. Example:
use Rose::Object::MakeMethods::Generic
(
boolean => 'last_modified_was_set',
);
...
__PACKAGE__->meta->setup(
...
columns => [
...
last_modified =>
{
type => 'timestamp',
on_set => sub { shift->last_modified_was_set(1) },
on_load => sub { shift->last_modified_was_set(0) },
on_save => sub
{
my($self) = shift;
$self->last_modified('now') unless($self->last_modified_was_set);
},
},
],
...
or a variation on that theme when overriding save(), load(), etc.
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object