How can I access a method of the consumer class inside a method created at runtime in a method of th
Posted
by xxxxxxx
on Stack Overflow
See other posts from Stack Overflow
or by xxxxxxx
Published on 2010-03-10T06:49:19Z
Indexed on
2010/03/24
20:23 UTC
Read the original article
Hit count: 542
I define a method inside a parametrized role that needs to create a new class at run time
using Moose::Meta::Class->create
and apply that exact parametrized role to it. I am also making a new method for that role using
$new_class->meta->add_method( some_name => sub {
my ($self) = @_;
...
})
inside the sub {...} I want to access a method of the consumer class and use it for something, I have tried using $self->get_method
, it didn't work, how do I do this?
Please notice that the $self
inside the sub above is MooseX::Role::Parameterized::Meta::Role::Parameterizable
I also have another question, if I do this:
my $object = Moose::Meta::Class->create(
"some_type",
);
Why isn't $object
of type some_type and it's some ugly MooseX::Role::Parameterized::Meta::Role::Parameterizable
and how do I get to the object of type some_type?
© Stack Overflow or respective owner