I'm trying to write MooseX::Role::Strict and am having problems (not surprising 
since this is my first attempt at hacking Moose).

My code is at http://github.com/Ovid/MooseX--Role--Strict/tree/master

I'm trying to provide my own meta class and using the following:

  use MooseX::Meta::Role::Strict;
  use Moose::Role -metaclass => 'MooseX::Meta::Role::Strict';
  use Moose::Exporter;
  Moose::Exporter->setup_import_methods( also => 'Moose::Role' );

If I don't 'use MooseX::Meta::Role::Strict' first, I fail with the following 
error message:

  Can't locate object method "initialize" via package 
"MooseX::Meta::Role::Strict"

Further, if I don't use Moose::Exporter and setup the import methods, my code 
doesn't recognize MooseX::Role::Strict as providing roles:

  package My::Role::Example;
  use MooseX::Role::Strict;

And using that (with 'My::Role::Example') generates the following:

  You can only consume roles, My::Role::Example is not a Moose role

 
Once I put those four lines together, the following test fails:

  isa_ok +My::Role::Example->meta, 'MooseX::Meta::Role::Strict';

With the following error message:

  not ok 1 - The object isa MooseX::Meta::Role::Strict
  #   Failed test 'The object isa MooseX::Meta::Role::Strict'
  #   at t/override.t line 17.
  #     The object isn't a 'MooseX::Meta::Role::Strict' it's a 
'Moose::Meta::Role'

So once I jump through all of the hoops I thought I needed, I've found that 
I've not set the metaclass.  What am I doing wrong?

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to