Browse files

Eliminate a layer of aliasing for the dumping methods.

* No need to keep the private dump methods around.
* Make "as_perl" the real one.  "perl" becomes just for backwards compat.
  • Loading branch information...
1 parent 8cdbb39 commit 628fb1e9973dc5f76a75da016c69bb0ce85c6f64 @schwern schwern committed Mar 6, 2013
Showing with 7 additions and 9 deletions.
  1. +7 −9 lib/perl5i/2/Meta/Instance.pm
View
16 lib/perl5i/2/Meta/Instance.pm
@@ -138,8 +138,8 @@ sub is_equal {
return perl5i::2::equal::are_equal($$$self, $other);
}
-sub as_perl{shift->perl(@_)}
-sub perl {
+*perl = \&as_perl;
+sub as_perl {
require Data::Dumper;
state $options = [qw(Terse Sortkeys Deparse)];
@@ -162,9 +162,9 @@ sub dump {
my $format = $args{format} // "perl";
state $dumpers = {
- json => "_dump_as_json",
- yaml => "_dump_as_yaml",
- perl => "perl",
+ json => "as_json",
+ yaml => "as_yaml",
+ perl => "as_perl",
};
my $dumper = $dumpers->{$format};
@@ -173,8 +173,7 @@ sub dump {
return $self->$dumper(%args);
}
-sub as_json { shift->_dump_as_json(@_)}
-sub _dump_as_json {
+sub as_json {
require JSON;
my $json = JSON->new
->utf8
@@ -198,8 +197,7 @@ sub _dump_as_json {
return $json->encode(${${$_[0]}});
}
-sub as_yaml { shift->_dump_as_yaml(@_)}
-sub _dump_as_yaml {
+sub as_yaml {
require YAML::Any;
return YAML::Any::Dump(${${$_[0]}});
}

0 comments on commit 628fb1e

Please sign in to comment.