Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

/var/sites/help-site.com/auto/tmp/CPAN/10532/Tree-Authz-0.03/lib/Tree/Authz/Role.pm

/var/sites/help-site.com/auto/tmp/CPAN/10532/Tree-Authz-0.03/lib/Tree/Authz/Role.pm

new( $role, $authz_class )
Represents a role.

name()
Returns the name of this role.

group_name()
DEPRECATED.

Use name instead.

authz
Returns the the Tree::Authz manpage subclass used to instantiate this role.

list_roles
Returns a list of roles inherited by this role, including this role.

setup_abilities( $name => $coderef, [ $name2 => $coderef2 ], ... )
Instance method.

Adds methods to the class representing the group. Keys give method names and values are coderefs that will be installed as methods on the group class:


    my $spies = $authz->get_group( 'spies' );

    my %able = ( read_secret => sub {

                    my ($self, $file) = @_;

                    open( SECRET, $file );

                    local $/;

                    <SECRET>;

                    },

                 find_moles => sub { ... },

                );

    $spies->setup_abilities( %able );

    if ( $spies->can( 'read_secret' ) ) {

        print $spies->read_secret( '/path/to/secret/file' );

    }

    # or

    if ( my $read = $spies->can( 'read_secret' ) ) {

        print $spies->$read( '/path/to/secret/file' );

    }

    # with an unknown $group

    my $get_secret = $group->can( 'read_secret' )       ||     # spy

                     $group->can( 'steal_document' )    ||     # mole

                     $group->can( 'create_secret' )     ||     # spymaster

                     $group->can( 'do_illicit_thing' )  ||     # politician

                     sub {};                                   # boring life

    my $secret = $group->$get_secret;

setup_plugins( $plugins )
Instance method.

Instead of adding a set of coderefs to a group's class, this method adds a class to the @ISA array of the group's class.


    package My::Spies;

    sub wear_disguise {}

    sub read_secret {

        my ($self, $file) = @_;

        open( SECRET, $file );

        local $/;

        <SECRET>;

    }

    package main;

    my $spies = $authz->get_group( 'spies' );

    $spies->setup_plugins( 'My::Spies' );

    if ( $spies->can( 'read_secret' ) ) {

        warn 'Compromised!';

        print $spies->read_secret( '/path/to/secret/file' );

    }

    warn 'Trust no-one' if $spies->can( 'wear_disguise' );

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy