NAME
Rose::ObjectX::CAF - Class::Accessor::Fast compatability for Rose::Object
SYNOPSIS
package MyClass;
use strict;
use base qw( Rose::ObjectX::CAF );
__PACKAGE__->mk_accessors(qw( foo bar ));
__PACKAGE__->mk_ro_accessors(qw( color name ));
1;
DESCRIPTION
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.
METHODS
new
Works like CAF, but may take a hash (the Rose::Object style) or hash ref (the CAF style).
init
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.
mk_accessors( @list_of_method_names )
Just like CAF.
mk_ro_accessors( @list_of_method_names );
Just like CAF, for read-only (accessor/getter) methods.
AUTHOR
Peter Karman, <karman at cpan.org>
BUGS
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.
SUPPORT
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
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
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.