Abilities
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Abilities.pm view on Meta::CPAN
Classes that consume this role will have the following methods available
to them:
=head2 can_perform( $action, [ $constraint ] )
Receives the name of an action, and possibly a constraint, and returns a true
value if the user/role can perform the provided action.
=cut
sub can_perform {
my ($self, $action, $constraint) = @_;
# a super-user/super-role can do whatever they want
return 1 if $self->is_super;
# return false if user/role doesn't have that ability
return unless $self->abilities->{$action};
# user/role has ability, but is there a constraint?
if ($constraint && $constraint ne '_all_') {
t/lib/TestCustomer.pm view on Meta::CPAN
use Moo;
use namespace::autoclean;
has 'name' => (
is => 'ro',
required => 1
);
has 'features' => (
is => 'ro',
default => sub { [] }
);
has 'plans' => (
is => 'ro',
default => sub { [] }
);
has 'mg' => (
is => 'ro',
required => 1,
);
with 'Abilities::Features';
sub get_plan {
my ($self, $plan) = @_;
return $self->mg->{$plan};
}
around qw/features plans/ => sub {
my ($orig, $self) = @_;
return @{$self->$orig || []};
};
1;
t/lib/TestManager.pm view on Meta::CPAN
package TestManager;
use warnings;
use strict;
sub new { bless {}, shift }
sub add_objects {
my $self = shift;
foreach (@_) {
$self->{$_->name} = $_;
}
return $self;
}
1;
t/lib/TestPlan.pm view on Meta::CPAN
use Moo;
use namespace::autoclean;
has 'name' => (
is => 'ro',
required => 1
);
has 'features' => (
is => 'ro',
default => sub { [] }
);
has 'plans' => (
is => 'ro',
default => sub { [] }
);
has 'mg' => (
is => 'ro',
required => 1,
);
with 'Abilities::Features';
sub get_plan {
my ($self, $plan) = @_;
return $self->mg->{$plan};
}
around qw/features plans/ => sub {
my ($orig, $self) = @_;
return @{$self->$orig || []};
};
1;
t/lib/TestRole.pm view on Meta::CPAN
use Moo;
use namespace::autoclean;
has 'name' => (
is => 'ro',
required => 1
);
has 'actions' => (
is => 'ro',
default => sub { [] }
);
has 'roles' => (
is => 'ro',
default => sub { [] }
);
has 'is_super' => (
is => 'ro',
default => sub { 0 }
);
has 'mg' => (
is => 'ro',
required => 1,
);
with 'Abilities';
sub get_role {
my ($self, $role) = @_;
return $self->mg->{$role};
}
around qw/actions roles/ => sub {
my ($orig, $self) = @_;
return @{$self->$orig || []};
};
1;
t/lib/TestUser.pm view on Meta::CPAN
use Moo;
use namespace::autoclean;
has 'name' => (
is => 'ro',
required => 1
);
has 'actions' => (
is => 'ro',
default => sub { [] }
);
has 'roles' => (
is => 'ro',
default => sub { [] }
);
has 'is_super' => (
is => 'ro',
default => sub { 0 }
);
has 'mg' => (
is => 'ro',
required => 1,
);
with 'Abilities';
sub get_role {
my ($self, $role) = @_;
return $self->mg->{$role};
}
around qw/actions roles/ => sub {
my ($orig, $self) = @_;
return @{$self->$orig || []};
};
1;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.267 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )