Type-Tiny
view release on metacpan or search on metacpan
lib/Eval/TypeTiny.pm view on Meta::CPAN
no warnings qw(void once uninitialized numeric);
use Type::Tiny ();
{
package #
Eval::TypeTiny::_TieArray;
require Tie::Array;
our @ISA = qw( Tie::StdArray );
sub TIEARRAY {
my $class = shift;
bless $_[0] => $class;
}
sub AUTOLOAD {
my $self = shift;
my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
defined tied(@$self) and return tied(@$self)->$method(@_);
require Carp;
Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
}
sub can {
my $self = shift;
lib/Eval/TypeTiny.pm view on Meta::CPAN
q[0+] => sub { 0 + tied @{$_[0]} },
);
}
{
package #
Eval::TypeTiny::_TieHash;
require Tie::Hash;
our @ISA = qw( Tie::StdHash );
sub TIEHASH {
my $class = shift;
bless $_[0] => $class;
}
sub AUTOLOAD {
my $self = shift;
my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
defined tied(%$self) and return tied(%$self)->$method(@_);
require Carp;
Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
}
sub can {
my $self = shift;
lib/Eval/TypeTiny.pm view on Meta::CPAN
q[0+] => sub { 0 + tied %{$_[0]} },
);
}
{
package #
Eval::TypeTiny::_TieScalar;
require Tie::Scalar;
our @ISA = qw( Tie::StdScalar );
sub TIESCALAR {
my $class = shift;
bless $_[0] => $class;
}
sub AUTOLOAD {
my $self = shift;
my ($method) = (our $AUTOLOAD =~ /(\w+)$/);
defined tied($$self) and return tied($$self)->$method(@_);
require Carp;
Carp::croak(qq[Can't call method "$method" on an undefined value]) unless $method eq 'DESTROY';
}
sub can {
my $self = shift;
t/20-modules/Type-Tiny-ConstrainedObject/basic.t view on Meta::CPAN
BEGIN {
package Local::Class;
use overload (
q[""] => sub { shift->as_string },
q[0+] => sub { shift->as_number },
fallback => 1,
);
sub new {
my $class = shift;
my %args = ref $_[0] ? %{$_[0]} : @_;
bless \%args => $class;
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
(my $method = $AUTOLOAD) =~ s/^.*:://;
$self->{$method};
}
sub DOES {
my $self = shift;
my ($role) = @_;
t/20-modules/Type-Tiny-Intersection/constrainedobject.t view on Meta::CPAN
BEGIN {
package Local::Class;
use overload (
q[""] => sub { shift->as_string },
q[0+] => sub { shift->as_number },
fallback => 1,
);
sub new {
my $class = shift;
my %args = ref $_[0] ? %{$_[0]} : @_;
bless \%args => $class;
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
(my $method = $AUTOLOAD) =~ s/^.*:://;
$self->{$method};
}
sub DOES {
my $self = shift;
my ($role) = @_;
t/20-modules/Type-Tiny-Union/constrainedobject.t view on Meta::CPAN
BEGIN {
package Local::Class;
use overload (
q[""] => sub { shift->as_string },
q[0+] => sub { shift->as_number },
fallback => 1,
);
sub new {
my $class = shift;
my %args = ref $_[0] ? %{$_[0]} : @_;
bless \%args => $class;
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
(my $method = $AUTOLOAD) =~ s/^.*:://;
$self->{$method};
}
sub DOES {
my $self = shift;
my ($role) = @_;
t/lib/Type/Puny.pm view on Meta::CPAN
my ($role) = @_;
return !!1 if {
'Type::API::Constraint' => 1,
'Type::API::Constraint::Constructor' => 1,
}->{$role};
"UNIVERSAL"->can("DOES") ? $proto->SUPER::DOES(@_) : $proto->isa(@_);
}
sub new { # Type::API::Constraint::Constructor
my $class = ref($_[0]) ? ref(shift) : shift;
my $self = bless { @_ == 1 ? %{+shift} : @_ } => $class;
$self->{constraint} ||= sub { !!1 };
unless ($self->{name}) {
require Carp;
Carp::croak("Requires both `name` and `constraint`");
}
$self;
}
( run in 0.793 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )