MooX::ClassStash - Extra class information for Moo
version 0.006
{ package MyClass; use Moo; use MooX::ClassStash; has i => ( is => 'ro' ); sub add_own_data { shift->class_stash->add_data(@_) } sub get_own_data { shift->class_stash->get_data(@_) } } # or with MooX { package MyClass; use MooX qw( ClassStash ); ... } my $class_stash = MyClass->class_stash; # or MyClass->new->class_stash print $class_stash->get_attribute( i => 'is' ); # 'ro' $class_stash->add_attribute( j => ( is => 'rw', )); print $class_stash->list_all_methods; print $class_stash->list_all_keywords; $class_stash->add_data( a => 1 ); # caller specific MyClass->add_own_data( a => 2 ); print $class_stash->get_data('a'); # 1 print MyClass->get_own_data('a'); # 2
The name of the class for the class stash.
The Package::Stash object of the given class.
HashRef of all the attributes set via "has" in Moo
HashRef with all the caller specific data stored.
ArrayRef which contains all the functions which are marked as keywords.
If you dont use "add_keyword" for installing a keyword, you might need to call this function to add the names of the keyword functions yourself.
Adds data to your, caller specific, data context of the class. First parameter is the key, second parameter will be the value.
Get your, caller specific, data. If you give a parameter, if will only give back the value of this key. If none is given, you get the HashRef of all the data stored.
Remove from your, caller specific, data the given key of the HashRef. There is no direct call to delete all the data at once.
Adds the given CodeRef as function to the package, but also add it to "keyword_functions" list, so that it gets excluded on method listings.
Get the CodeRef of the given keyword. Technical identical to "get_method".
Checks for the given keyword. Technical identical to "has_method".
Remove the function from the package, but also remove it from "keyword_functions" list.
It is the same like calling "has" in Moo inside the package.
If you want it, implement it... ;)
Add a method to the class.
Get the CodeRef of the given method name.
Checks if the given method exist.
Delete the given method from the class.
List all methods of the class. This method fetches all functions of the package and filters out the keywords from "keyword_functions".
Install an after modifier on the function given by the first parameter, with the CodeRef given as second parameter. See "after" in Moo.
Install a before modifier on the function given by the first parameter, with the CodeRef given as second parameter. See "before" in Moo.
Install an around modifier on the function given by the first parameter, with the CodeRef given as second parameter. See "around" in Moo.
Torsten Raudssus <torsten@raudss.us>
This software is copyright (c) 2012 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooX::ClassStash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooX::ClassStash
CPAN shell
perl -MCPAN -e shell install MooX::ClassStash
For more information on module installation, please visit the detailed CPAN module installation guide.