Class-Variable
view release on metacpan or search on metacpan
lib/Class/Variable.pm view on Meta::CPAN
12345678910111213141516package
Class::Variable;
use
5.008;
use
Carp;
our
$VERSION
=
'1.002'
;
# <== update version in pod
our
@EXPORT
;
my
$NS
= {};
push
@EXPORT
,
'public'
;
sub
public($;)
{
lib/Class/Variable.pm view on Meta::CPAN
555657585960616263646566676869707172737475
{
my
$self
=
shift
;
if
(
not
exists
$NS
->{
$self
}
or not
defined
$NS
->{
$self
}->{
' self'
}
)
{
$NS
->{
$self
} = {
' self'
=>
$self
};
weaken
$NS
->{
$self
}->{
' self'
};
}
$NS
->{
$self
}->{
$name
};
};
}
sub
get_protected_variable($$)
{
my
(
$package
,
$name
) =
@_
;
lib/Class/Variable.pm view on Meta::CPAN
777879808182838485868788899091929394959697{
my
$self
=
shift
;
if
(
not
exists
$NS
->{
$self
}
or not
defined
$NS
->{
$self
}->{
' self'
}
)
{
$NS
->{
$self
} = {
' self'
=>
$self
};
weaken
$NS
->{
$self
}->{
' self'
};
}
croak
sprintf
(
"Access violation: protected variable %s of %s available only to class or subclasses, but not %s."
,
$name
||
'undefined'
,
$package
||
'undefined'
,
caller
() ||
'undefined'
)
if
not
caller
()->isa(
$package
);
$NS
->{
$self
}->{
$name
};
};
lib/Class/Variable.pm view on Meta::CPAN
105106107108109110111112113114115116117118119120121122123124125{
my
$self
=
shift
;
if
(
not
exists
$NS
->{
$self
}
or not
defined
$NS
->{
$self
}->{
' self'
}
)
{
$NS
->{
$self
} = {
' self'
=>
$self
};
weaken
$NS
->{
$self
}->{
' self'
};
}
croak
sprintf
(
"Access violation: private variable %s of %s available only to class itself, not %s."
,
$name
||
'undefined'
,
$package
||
'undefined'
,
caller
() ||
'undefined'
)
if
caller
() ne
$package
;
$NS
->{
$self
}->{
$name
};
};
( run in 0.359 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )