Entities::Role - A collection of possibly related actions granted to users.
used internally, see L<Entities>
A role is merely a collection of actions. Users are assigned to these roles to easily provide them with abilities they might need, probably to perform their 'roles' in a webapp (think of roles such as 'admins', 'members', 'vandal_fighters' or 'trolls'; probably not trolls though).
Roles can inherit all action of other roles, to allow for a structured authorization-system that is easier to apply and follow.
NOTE: you are not meant to create role objects directly, but only through the
new_role() method in Entities.
Creates a new instance of this module. Only 'name' is required.
Returns the ID of the role, if set.
Returns a true value if the role object has an ID attribute.
Sets the ID of the role object to the provided value. Only to be used internally.
Returns the name of the role.
Returns the description text of this role.
Changes the description text of the object to the provided text.
In scalar context, returns an array-ref of all role names this role inherits from. In list context returns an array. If an array-ref of role names is provided, it will replace the current list.
Returns a true value if the role inherits from any other roles.
In scalar context, returns an array-ref of all action names this role has. In list context returns an array. If an array-ref of action names is provided, it will replace the current list.
Returns a true value if the role has been granted any actions.
Returns an array of all action names this role has been granted.
Returns a true value if this role is considered a super-role. Super roles can do every possible action, in ANY SCOPE.
Returns a DateTime object in the time the role object has been created.
Returns a DateTime object in the last time the object has been modified. If a DateTime object is provided, it is set as the new modified value.
Returns the Entities::Backend instance that stores this object.
Returns a true value if the role has been explicitely grant the action named
$action_named (i.e. not through inheritance).
Grants the action named
$action_name to the role. Croaks if the action does not exist, warns if the role has already been granted this action.
Returns the role object itself.
Removes the action named
$action_name from the list of actions the role has been explictely granted to perform. This doesn't necessarily mean the role will not be able to perform this action anymore, as it might be available to it via inherited roles. Warns if the role wasn't granted this action, does not croak if the action does not exist. Returns the role object itself.
Sets up an inheritance between the current role object and the role whose name is
$role_name. Croaks if
$role_name cannot be found, warns if such an inheritance already exists.
Returns the role object itself.
This badly named method drops the inheritance from the role named
$role_name. Warns if the role object doesn't inherit from the provided role, does not croak if the provided role does not even exist. Returns the role object itself.
Returns the role object of the role named
The following list documents any method modifications performed through the magic of Moose.
actions() methods are called with no arguments and in list context - will automatically dereference the array-ref into arrays.
Automatically saves the object to the backend after any method that changed it was executed. Also updates the 'modified' attribute with the current time before saving. Note, however, that the
action() methods are not here, since they are only meant to be used for writing internally.
<ido at ido50 dot net>
Please report any bugs or feature requests to
bug-entities at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Entities. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2010-2013 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.