App-perlimports

 view release on metacpan or  search on metacpan

lib/App/perlimports/ExportInspector.pm  view on Meta::CPAN

package App::perlimports::ExportInspector;

use Moo;

## no critic (Modules::RequireExplicitInclusion, Subroutines::ProhibitCallsToUnexportedSubs, TestingAndDebugging::ProhibitNoStrict)

our $VERSION = '0.000061';

use App::perlimports::Sandbox ();
use Class::Inspector          ();
use List::Util                qw( any );
use Module::Runtime           qw( require_module );
use Sub::HandlesVia;
use Try::Tiny       qw( catch try );
use Types::Standard qw(ArrayRef Bool HashRef Int InstanceOf Str);

with 'App::perlimports::Role::Logger';

has at_export => (
    is      => 'ro',
    isa     => ArrayRef [Str],
    lazy    => 1,
    default => sub { shift->_implicit->{export} },
);

# Explicit accessor rather than a Sub::HandlesVia 'count' delegation. Array
# handlers route through the Sub::HandlesVia::XS backend, whose XS array handler
# caches the Perl stack pointer across the attribute builder's call_sv and can
# write through it after the builder has reallocated the stack. See issue #171.
sub has_at_export { return scalar @{ $_[0]->at_export }; }

has at_export_ok => (
    is      => 'ro',
    isa     => ArrayRef [Str],
    lazy    => 1,
    default => sub { shift->_implicit->{export_ok} },
);

# Explicit accessor rather than a Sub::HandlesVia 'count' delegation; see the
# note on has_at_export above and issue #171. (An unused 'elements' delegation
# was dropped here at the same time.)
sub has_at_export_ok { return scalar @{ $_[0]->at_export_ok }; }

has at_export_fail => (
    is      => 'ro',
    isa     => ArrayRef [Str],
    lazy    => 1,
    default => sub { shift->_implicit->{export_fail} },
);

has at_export_tags => (
    is      => 'ro',
    isa     => ArrayRef [Str],
    lazy    => 1,
    default => sub { shift->_implicit->{export_tags} },
);

has class_isa => (
    is      => 'ro',
    isa     => ArrayRef [Str],
    lazy    => 1,
    default => sub { shift->_implicit->{class_isa} },
);

has has_fatal_error => (
    is      => 'ro',
    isa     => Bool,
    lazy    => 1,
    default => sub {
        my $self = shift;
        (          $self->_implicit->{fatal_error}
                || $self->explicit_exports->{fatal_error} )
            ? 1
            : 0;



( run in 3.037 seconds using v1.01-cache-2.11-cpan-9e1a9122474 )