YAML
view release on metacpan or search on metacpan
lib/YAML/Mo.pm view on Meta::CPAN
package YAML::Mo;
# use Mo qw[builder default import];
# The following line of code was produced from the previous line by
# Mo::Inline version 0.4
no warnings;my$M=__PACKAGE__.'::';*{$M.Object::new}=sub{my$c=shift;my$s=bless{@_},$c;my%n=%{$c.'::'.':E'};map{$s->{$_}=$n{$_}->()if!exists$s->{$_}}keys%n;$s};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.'::';shift;eval"no Mo::$_",&{...
our $DumperModule = 'Data::Dumper';
my ($_new_error, $_info, $_scalar_info);
no strict 'refs';
*{$M.'Object::die'} = sub {
my $self = shift;
my $error = $self->$_new_error(@_);
$error->type('Error');
Carp::croak($error->format_message);
};
*{$M.'Object::warn'} = sub {
my $self = shift;
return unless $^W;
my $error = $self->$_new_error(@_);
$error->type('Warning');
Carp::cluck($error->format_message);
};
# This code needs to be refactored to be simpler and more precise, and no,
# Scalar::Util doesn't DWIM.
#
# Can't handle:
# * blessed regexp
*{$M.'Object::node_info'} = sub {
my $self = shift;
my $stringify = $_[1] || 0;
my ($class, $type, $id) =
ref($_[0])
? $stringify
? &$_info("$_[0]")
: do {
require overload;
my @info = &$_info(overload::StrVal($_[0]));
if (ref($_[0]) eq 'Regexp') {
@info[0, 1] = (undef, 'REGEXP');
}
@info;
}
: &$_scalar_info($_[0]);
($class, $type, $id) = &$_scalar_info("$_[0]")
unless $id;
return wantarray ? ($class, $type, $id) : $id;
};
#-------------------------------------------------------------------------------
$_info = sub {
return (($_[0]) =~ qr{^(?:(.*)\=)?([^=]*)\(([^\(]*)\)$}o);
};
$_scalar_info = sub {
my $id = 'undef';
if (defined $_[0]) {
\$_[0] =~ /\((\w+)\)$/o or CORE::die();
$id = "$1-S";
}
return (undef, undef, $id);
};
( run in 2.397 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )