Object::Botox - simple object constructor with accessor, prototyping and default-settings of inheritanced values.
Version 1.15
Object::Botox writed for easy object creation by default constructor and support managment properties, inherited by children of prototyping class.
package Parent; use Botox; # yes, we now are got |new| constructor # default properties for ANY object of `Parent` class: # prop1_ro ISA 'write-protected' && prop2 ISA 'public' # and seting default value for each other # strictly named constant PROTOTYPE ! use constant PROTOTYPE => { 'prop1_ro' => 1 , 'prop2' => 'abcde' };
Object::Botox - simple constructor and properties prototyper whith checking of properties existans.
To create parent module:
package Parent; use Botox; # strictly named constant PROTOTYPE ! use constant PROTOTYPE => { 'prop1_ro' => 1 , 'prop2' => 'abcde' }; sub show_prop1{ # It`s poinlessly - indeed property IS A accessor itself my ( $self ) = @_; return $self->prop1; } sub set_prop1{ # It`s NEEDED for RO aka protected on write property my ( $self, $value ) = @_; $self->prop1($value); } sub parent_sub{ # It`s class method itself my $self = shift; return $self->prop1; } 1;
after that we are create instanse:
package main; use Data::Dumper; # change default value for prop1 my $foo = new Parent( { prop1 => 888888 } ); print Dumper($foo);
outputs get to us:
$VAR1 = bless( { 'Parent::prop1' => 888888, 'Parent::prop2' => 'abcde' }, 'Parent' );
properties may have _rw[default] or _ro acess mode and inheritated.
eval{ $foo->prop1(-23) }; print $@."\n";
output somthing like this:
Can`t change RO properties |prop1| to |-23| in object Parent from main at ./test_more.t line 84
to deal (write to) with this properties we are must create accessor .
Also all of properties are inheritanced.
package Child; use base 'Parent'; use constant PROTOTYPE => { 'prop1' => 48, 'prop5' => 55, 'prop8_ro' => 'tetete' }; 1;
give to us something like this
$VAR1 = bless( { 'Child::prop5' => 55, 'Child::prop2' => 'abcde', 'Child::prop1' => 48, 'Child::prop8' => 'tetete' }, 'Child' );
Chainings - all setter return $self in success, so its chained
$baz->prop1(88)->prop2('loreum ipsum');
new() method by default
new() - create object (on hashref-base) by prototype and initiate it from args
Moose, Mouse, Class::Accessor, Class::XSAccessor
Meettya, <meettya at cpan.org>
<meettya at cpan.org>
Please report any bugs or feature requests to bug-object-botox at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-Botox. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-object-botox at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Object::Botox
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-Botox
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Object-Botox
CPAN Ratings
http://cpanratings.perl.org/d/Object-Botox
Search CPAN
http://search.cpan.org/dist/Object-Botox/
Copyright 2011 Meettya.
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 Object::Botox, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Botox
CPAN shell
perl -MCPAN -e shell install Object::Botox
For more information on module installation, please visit the detailed CPAN module installation guide.