in reply to Role::Tiny Moo::Role question on getting dymanic requires

Not sure I understand what you mean by "what the requires are" ... or by "a list of methods that are required in order to compose a role".

Do you mean the attributes of the class that are required to be populated when you instantiate it, ie required arguments?

The way forward always starts with a minimal test.
  • Comment on Re: Role::Tiny Moo::Role question on getting dymanic requires

Replies are listed 'Best First'.
Re^2: Role::Tiny Moo::Role question on getting dymanic requires
by tmaly (Monk) on Apr 05, 2016 at 19:01 UTC

    Under Role::Tiny there is a
    requires qw(foo bar);
    Described as "Declares a list of methods that must be defined to compose role."
    I am looking for a way to introspect a role from the outside to determine if any requires has been declared and what specific methods were declared in the requires. In this case foo and bar.

      There's no official way to do that, but if you can live with an undocumented approach, you can inspect $Role::Tiny::INFO{YourRole}{requires} e.g.
      package BasicRole; use Moo::Role; requires qw(abra cadabra); 1; package App; use Moo; with 'BasicRole'; sub abra { 'abra' } sub cadabra { 'cadabra' } 1; package main; use strict; use Data::Dump 'dd'; my $app = App->new(); dd $Role::Tiny::INFO{BasicRole}{requires}; __END__ Output: ["abra", "cadabra"]
        I am limited to a Moo / Role::Tiny , Moose is not an option.
        Food dishes by location Bestfoodnearme.com