Hi Monks, Suppose i have the following class:
package GSM::Cell; use Moose; use MooseX::AttributeHelpers; with qw(GSM::Cell::Role::BcchChecks); has 'BCCH' => (is => 'rw', required => 1); has 'LAC' => (is => 'ro', required => 1); has 'CI' => (is => 'ro', required => 1); has 'ADJACENCIES' => ( metaclass => 'Collection::Hash', is => 'rw', isa => 'HashRef', default => sub {+{}}, provides => { exists => 'exists_adjacency', keys => 'adjacency_IDs', get => 'get_adjacency', set => 'add_adjacency', }, ); 1;
and a little later i have the following role :
package GSM::Cell::Role::BcchChecks; use Moose::Role; #requires qw(get_adjacency); # - error sub list_bcchs { my $self = shift; my %list = map {$_->BCCH => 1} $self , map($self->get_adjacency($_ +)->CELL , $self->adjacency_IDs); my @list = sort keys %list; @list; } 1;
If i uncomment the requires qw(get_adjacency) in GSM::Cell::Role::BcchChecks i get the error GSM::Cell::Role::BcchChecks requires the method 'get_adjacency' to be implemented by 'GSM::Cell' even though the method "get_adjacency" is a valid method that is auto-provided when using MooseX::AttributeHelpers. How can i nevertheless enable such a check? I would ideally like to avoid a  croak "Not a GSM::Cell" unless $self->isa('GSM::Cell') type of solution.

In reply to Checking for required methods that were auto-generated by MooseX::AttributeHelpers by ZAmonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.