On Tue, May 18, 2010 at 10:11 PM, Kate Yoak <k...@yoak.com> wrote: > Hi all, > > I am using an ORM, which creates methods for my class using globs, in place. > > e.g. __PACKAGE__->has_a('foo'...); > > now I have a foo() method defined in my namespace. > > I thought that I could use method modifiers to supplement the created methods: > > around foo => sub{ > ..... > }; > > This failed to work, complaining that the method was not found in the class's > inheritance hierarchy. Is this the expected behavior? > > The workaround is easy, changing the original foo to _foo and making > hand-written foo() call it. I am just curious to understand how things are > supposed to work. :-)
I'm curious -- what happens if you wrap the __PACKAGE__->has_(...) in a BEGIN { }? If it works after that, then I suspect the following modifier will enable other modifiers against ORM-generated methods to work as expected: after has_a => sub { my ($class, $method_name) = (shift, shift); my $method = Moose::Meta::Method->wrap( associated_metaclass => $class->meta, package_name => $class, name => $method_name, body => $class->meta->get_all_package_symbols('CODE')->{$method_name}, ); $class->meta->add_method($method_name => $method); }; -Chris -- Chris Weyl Ex astris, scientia