Class-InsideOut
view release on metacpan or search on metacpan
register( $reference, $class ); # automatic bless
register( $class ); # automatic blessed scalar
Registers objects for thread-safety. This should be called as part of a
constructor on a object blessed into the current package. Returns the
resulting object. When called with only a class name, "register" will
bless an anonymous scalar reference into the given class. When called
with both a reference and a class name, "register" will bless the
reference into the class.
OPTIONS
Options customize how properties are generated. Options may be set as a
default with the "options" function or passed as a hash reference to
"public", "private" or "property".
Valid options include:
"privacy"
property rank => my %rank, { privacy => 'public' };
property serial => my %serial, { privacy => 'private' };
If the *privacy* option is set to *public*, an accessor will be created
with the same name as the label. If the accessor is passed an argument,
the property will be set to the argument. The accessor always returns
the value of the property.
"get_hook"
public list => my %list, {
get_hook => sub { @$_ }
};
Defines an accessor hook for when values are retrieved. $_ is locally
aliased to the property value for the object. *The return value of the
hook is passed through as the return value of the accessor.* See
"Customizing Accessors" in Class::InsideOut::Manual::Advanced for
details.
The hook must be a coderef, including blessed coderefs and overloaded
objects.
"set_hook"
public age => my %age, {
set_hook => sub { /^\d+$/ or die "must be an integer" }
};
Defines an accessor hook for when values are set. The hook subroutine
receives the entire argument list. $_ is locally aliased to the first
argument for convenience. The property receives the value of $_. See
"Customizing Accessors" in Class::InsideOut::Manual::Advanced for
details.
The hook must be a coderef, including blessed coderefs and overloaded
objects.
SEE ALSO
Programmers seeking a more full-featured approach to inside-out objects
are encouraged to explore Object::InsideOut. Other implementations are
also noted in Class::InsideOut::Manual::About.
KNOWN LIMITATIONS
Requires weak reference support (Perl >= 5.6) and Scalar::Util::weaken()
to avoid memory leaks and to provide thread-safety.
ROADMAP
Features slated for after the 1.0 release include:
* Adding support for Data::Dump::Streamer serialization hooks
* Adding additional accessor styles (e.g. get_name()/set_name())
* Further documentation revisions and clarification
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at
<https://github.com/dagolden/class-insideout/issues>. You will be
notified automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
<https://github.com/dagolden/class-insideout>
git clone https://github.com/dagolden/class-insideout.git
AUTHOR
David Golden <dagolden@cpan.org>
CONTRIBUTORS
* Karen Etheridge <ether@cpan.org>
* Toby Inkster <tonyink@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2006 by David A. Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
( run in 0.506 second using v1.01-cache-2.11-cpan-39bf76dae61 )