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

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.

  • Comment on Re^2: Role::Tiny Moo::Role question on getting dymanic requires

Replies are listed 'Best First'.
Re^3: Role::Tiny Moo::Role question on getting dymanic requires
by Arunbear (Prior) on Apr 06, 2016 at 12:09 UTC
    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"]
Re^3: Role::Tiny Moo::Role question on getting dymanic requires
by 1nickt (Canon) on Apr 05, 2016 at 20:07 UTC
      I am limited to a Moo / Role::Tiny , Moose is not an option.
      Food dishes by location Bestfoodnearme.com