X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI.pm;h=a5c65f65166c417f1171ee051e97768713ee188e;hp=dd9af06c71472df111a129e51bda562173becf65;hb=f19715f56244cc6d862169c2dd656b8a2f3845b5;hpb=3886be13f39d6d3fc8d0b76d4716175df1bb8056 diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index dd9af06..a5c65f6 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -29,7 +29,7 @@ use Class::DBI::Plugin::RetrieveAll; use Class::DBI::Pager; use Lingua::EN::Inflect::Number qw(to_PL); - +use attributes (); ############################################################################### # Helper methods @@ -301,29 +301,6 @@ sub adopt { } } -=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) @@ -333,7 +310,7 @@ 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; @@ -348,20 +325,12 @@ Tell if action is a object method (See Maypole::Plugin::Menu) 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