view Lib/IMPL/Security/Role.pm @ 122:a7efb3117295

Fixed bug in IMPL::DOM::Navigator::selectNodes Fixed bug in IMPL::DOM::Node::selectNodes renamed operator 'type' to 'typeof' in IMPL::Object::Abstract A proper implementation of the IMPL::DOM::Node::nodeProperty and a related changes in the IMPL::DOM::Property module, now the last is very simple.
author wizard
date Tue, 08 Jun 2010 20:12:45 +0400 (2010-06-08)
parents 79bf75223afe
children b56ebc31bf18
line wrap: on
line source
package IMPL::Security::Role;

use base qw(IMPL::Object);

use IMPL::Class::Property;

BEGIN {
	public property roleName => prop_get | owner_set;
	public property parentRoles => prop_get | owner_set | prop_list;
}

sub CTOR {
	my ($this,$name,$parentRoles) = @_;
	
	$this->roleName($name);
	$this->parentRoles($parentRoles);
}

sub Satisfy {
	my ($this,@roles) = @_;	
	
	return 1 unless $this->_FilterRoles( @roles );
	return 0;
}

sub _FilterRoles {
	my ($this,@roles) = @_;
	
	@roles = grep not (ref $_ ? $this == $_ : $this->roleName eq $_), @roles;
	
	@roles = $_->_FilterRoles(@roles) or return foreach $this->parentRoles ;
	
	return @roles;
}


1;

__END__

=pod

=head1 NAME

C<IMPL::Security::Role> ����

=head1 DESCRIPTION

����� �������� � ���� ������� ����.
������� ����� ��� �������� ������� ����������� ����� � ������� ����.

=head1 MEMBERS

=over

=item C<[get] roleName>

��� ����, �� �������������

=item C<[get,list] parentRoles>

������ ������������ �����

=item C<Satisfy(@roles_list)>

��������� ������� ����� ��������� ����� �� ������ @roles_list.
����������� ������������� ��� ����� ��������, ��� � ���� �����.
���������� 0 � ������ �������, 1 ��� ������� ����������� �����

=back

=cut