NAME
Sub::Attributes - meta programming with subroutine attributes
SYNOPSIS
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'], ... }
METHODS
sub_attributes
Returns a hashref of subroutine names and their attributes.
SEE ALSO
AUTHOR
© 2016 David Farrell
LICENSE
See LICENSE
REPOSITORY
https://github.com/dnmfarrell/Sub-Attributes