use Class::DBI::Pager;
use Lingua::EN::Inflect::Number qw(to_PL);
-
+use attributes ();
###############################################################################
# Helper methods
}
}
-=head2 is_public
-
-Should return true if a certain action is supported, or false otherwise.
-Defaults to checking if the sub has the C<:Exported> attribute.
-
-=cut
-
-sub is_public {
- my ( $self, $action, $attrs ) = @_;
- my $cv = $self->can($action);
- warn "is_public failed . action is $action. self is $self" and return 0 unless $cv;
- unless ($attrs) {
- my @attrs = attributes::get($cv) || ();
- $attrs = join " ", @attrs;
- }
- do {
- warn "is_public failed .$action not exported" if Maypole->debug;
- return 0;
- } unless $attrs =~ /\bExported\b/i;
- return 1;
-}
-
-
=head2 is_class
Tell if action is a class method (See Maypole::Plugin::Menu)
sub is_class {
my ( $self, $method, $attrs ) = @_;
die "Usage: method must be passed as first arg" unless $method;
- $attrs = $self->method_attrs($method) unless ($attrs);
+ $attrs = join(' ',$self->method_attrs($method)) unless ($attrs);
return 1 if $attrs =~ /\bClass\b/i;
return 1 if $method =~ /^list$/; # default class actions
return 0;
sub is_object {
my ( $self, $method, $attrs ) = @_;
die "Usage: method must be passed as first arg" unless $method;
- $attrs = $self->method_attrs($method) unless ($attrs);
+ $attrs = join(' ',$self->method_attrs($method)) unless ($attrs);
return 1 if $attrs =~ /\bObject\b/i;
return 1 if $method =~ /(^view$|^edit$|^delete$)/; # default object actions
return 0;
}
-# Get string of joined attributes for matching
-sub method_attrs {
- my ($class, $method) = @_;
- my $cv = $class->can($method);
- return 0 unless $cv;
- my @attrs = attributes::get($cv) || ();
- return join " ", @attrs;
-}
=head2 related