- COPYRIGHT & LICENSE
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 );
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.
<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.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
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.