NAME
MooX::ClassStash - Extra class information for Moo
VERSION
version 0.002
SYNOPSIS
{
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 L<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
DESCRIPTION
ATTRIBUTES
class
The name of the class for the class stash.
class
The Package::Stash object of the given class
attributes
HashRef of all the attributes set via "has" in Moo
data
HashRef with all the caller specific data stored.
keyword_functions
ArrayRef which contains all the functions which are marked as keywords.
METHODS
add_keyword_functions
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.
add_data
Adds data to your, caller specific, data context of the class. First parameter is the key, second parameter will be the value.
get_data
Get your, caller specific, data. If you give a paramter, if will only give back the value of this key. If none is given, you get a HashRef of all the data stored.
remove_data
add_keyword
get_keyword
has_keyword
remove_keyword
get_or_add_keyword_keyword
add_attribute
It is the same like calling "has" in Moo inside the package.
get_attribute
has_attribute
remove_attribute
Not implemented yet
get_or_add_attribute
Not implemented yet
list_all_keywords
add_method
get_method
has_method
remove_method
get_or_add_method
list_all_methods
after_method
before_method
around_method
AUTHOR
Torsten Raudssus <torsten@raudss.us>
COPYRIGHT AND LICENSE
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.