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
use warnings;
package CLR_X; # class-less root
# 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
use warnings;
package InstanceX;
use Scalar::Util qw(blessed);
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 all matches for this distributionview release on metacpan - search on metacpan
( run in 0.596 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )