Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Modules for autogenerating accessor/mutator methods

by wolv (Pilgrim)
on Jun 05, 2005 at 19:43 UTC ( [id://463761]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Modules for autogenerating accessor/mutator methods
in thread Modules for autogenerating accessor/mutator methods

Mind you, Attribute::Property generates lvalue subroutines, so a simple 'sub email { }' won't replace the interface in a compatible way. Furthermore, A::P supports adding validation and processing: sub email : Property { process; validate } The return value of the block will indicate whether the value given validates.

Replies are listed 'Best First'.
Re^4: Modules for autogenerating accessor/mutator methods
by magog (Beadle) on Jun 05, 2005 at 20:17 UTC

    Hmmm... That's a good point. It's the same thing with Class::Accessor::Lvalue. When you want to upgrade to a full method, you're stuck: there doesn't seem to be an easy way to make an lvalue subroutine that has access to the rvalue.

    Update: But you're right - Attribute::Property does allow you to do all the processing you want, as long as you follow it's rules. So it's probably enough.

    Update: For instance, you could do:

    sub email : Property { my $self = shift; $_ = 'some_arbitrary@address.com'; 1; } # ... # user code $self->email = 'my@address.com'; print $self->email; # prints some_arbitrary@address.com

    Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-05-30 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found