Rose::ObjectX::CAF - Class::Accessor::Fast compatability for Rose::Object
package MyClass; use strict; use base qw( Rose::ObjectX::CAF ); __PACKAGE__->mk_accessors(qw( foo bar )); __PACKAGE__->mk_ro_accessors(qw( color name )); 1;
Rose::ObjectX::CAF is a compatability layer for Class::Accessor::Fast users who want to migrate to Rose::Object.
As evidenced in App::Benchmark::Accessors, Rose::Object + Class::XSAccessor is much faster than Class::Accessor::Fast (and more extensible). I decided to switch over, but had a lot of code already using CAF. So this class was born to make the migration easier.
Just replace this line in your classes:
use base qw( Class::Accessor::Fast );
with this:
use base qw( Rose::ObjectX::CAF );
and no other changes should be necessary.
Works like CAF, but may take a hash (the Rose::Object style) or hash ref (the CAF style).
Like Rose::Object, called by new(). Do not override new() in your subclasses; override init() instead. And be sure to call:
$self->SUPER::init(@_); # or with MRO::Compat, $self->next::method(@_);
in your subclass.
Rather than calling the method name for each param passed in new(), the value is simply set in the object as a hash ref. This assumes every object is a blessed hash ref.
The reason the hash is preferred over the method call is to support read-only accessors, which will croak if init() tried to set values with them.
Just like CAF.
Just like CAF, for read-only (accessor/getter) methods.
Peter Karman, <karman at cpan.org>
<karman at cpan.org>
Please report any bugs or feature requests to bug-rose-objectx-caf at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rose-ObjectX-CAF. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-rose-objectx-caf at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Rose::ObjectX::CAF
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Rose-ObjectX-CAF
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Rose-ObjectX-CAF
CPAN Ratings
http://cpanratings.perl.org/d/Rose-ObjectX-CAF
Search CPAN
http://search.cpan.org/dist/Rose-ObjectX-CAF/
Copyright 2009 Peter Karman.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Rose::ObjectX::CAF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rose::ObjectX::CAF
CPAN shell
perl -MCPAN -e shell install Rose::ObjectX::CAF
For more information on module installation, please visit the detailed CPAN module installation guide.