Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Re: RFC: transactions.pm

by particle (Vicar)
on Apr 28, 2003 at 17:27 UTC ( [id://253755]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: RFC: transactions.pm
in thread RFC: Transactions.pm

I'm open to suggestions, but not to DBIx::. This module has a much wider scope. Currently, I know of no other modules that use begin_work, rollback and commit, but in theory any transaction capable module could be used with this.

...then don't tie people in to the method names, provide them with the ability to redefine them. a caller might do:

use My::Transactions 0.01 begin_work => try_it, rollback => fallback, commit => do_it;

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: Re: Re: RFC: transactions.pm
by Juerd (Abbot) on Apr 28, 2003 at 18:02 UTC

    ...then don't tie people in to the method names, provide them with the ability to redefine them.

    Subclass or wrap all you want. Perl already has perfect features to support what you wish :)

    Here are three examples to accomplish this task, but there a lot of other ways to do it.

    # 1) subclassing package Foo::Bar::Sub; use base 'Foo::Bar'; sub begin_work { shift->try_it } sub commit { shift->do_it } sub begin_work { shift->try_it } # 2) wrapping package Foo::Bar::Wrap; use Attribute::Property; use Scalar::Util qw(blessed) sub new : New; sub object : Property { blessed } sub begin_work { shift->object->try_it } sub commit { shift->object->do_it } sub rollback { shift->object->fallback } # 3) intruding sub Foo::Bar::begin_work { shift->try_it } sub Foo::Bar::commit { shift->do_it } sub Foo::Bar::rollback { shift->fallback }

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://253755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found