Sub::Attributes - meta programming with subroutine attributes
package Point; use base 'Sub::Attributes'; # croak if not called as a class method sub new :ClassMethod { ... } # croak if not called as object method sub add : Method { ... } # private subroutine, will croak unless called from within Point package sub _internal_logic : Private Method { ... } # Typical method modifiers ala LISP & Class::Method::Modifiers # before, after & around all occur at compile time sub check_state : Before(add) { ... } sub doubleme : After(add) { ... } # orig is a coderef to add, it needs to be given $self becase it's an object # method sub filter_calls : Around(add) { my ($orig, $self, @args) = @_; my $result = $orig->($self, @args); ... } package main; my $p = Point->new(3,8); $p->sub_attributes(); # { add => ['Method'], _internal_logic => ['Private','Method'], ... }
Returns a hashref of subroutine names and their attributes.
Class::Method::Modifiers
MooseX::MethodAttributes
© 2016 David Farrell
See LICENSE
https://github.com/dnmfarrell/Sub-Attributes
https://github.com/dnmfarrell/Sub-Attributes/issues
To install Sub::Attributes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Attributes
CPAN shell
perl -MCPAN -e shell install Sub::Attributes
For more information on module installation, please visit the detailed CPAN module installation guide.