MRO-Magic
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/lib/CLR.pm view on Meta::CPAN
234567891011121314151617181920212223242526272829303132333435363738394041use
warnings;
# Our test example will be a very, very simple classless/prototype calling
# system. -- rjbs, 2008-05-16
sub
new {
my
(
$class
,
%attrs
) =
@_
;
my
$root
= {
new
=>
sub
{
my
(
$parent
,
%attrs
) =
@_
;
bless
{
%attrs
,
parent
=>
$parent
} =>
$class
;
},
get
=>
sub
{
my
(
$self
,
$attr
) =
@_
;
my
$curr
=
$self
;
while
(
$curr
) {
return
$curr
->{
$attr
}
if
exists
$curr
->{
$attr
};
$curr
=
$curr
->{parent};
}
return
undef
;
},
set
=>
sub
{
my
(
$self
,
$attr
,
$value
) =
@_
;
return
$self
->{
$attr
} =
$value
;
},
%attrs
,
parent
=>
undef
,
};
bless
$root
=>
$class
;
}
my
%STATIC
= (
new
=> \
&new
);
use
MRO::Magic
passthru
=> [
qw(import export DESTROY AUTOLOAD)
],
metamethod
=>
sub
{
my
(
$invocant
,
$method
,
$args
) =
@_
;
unless
(
ref
$invocant
) {
t/lib/Instance.pm view on Meta::CPAN
view all matches for this distribution
2345678910111213141516171819202122use
warnings;
package
InstanceX;
our
$VERSION
=
'1.000'
;
my
%STATIC
= (
new
=>
sub
{
my
(
$class
,
$arg
) =
@_
;
bless
$arg
=>
$class
;
}
);
my
%UNIVERSAL
= (
class
=>
sub
{
$_
[0]->{__class__} },
# shout out to my homies in python
isa
=>
sub
{
return
$_
[0]->class->derives_from(
$_
[1]); },
);
sub
invoke_method {
my
(
$invocant
,
$method_name
,
$args
) =
@_
;
view release on metacpan - search on metacpan
( run in 1.308 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )