Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adding the as_* methods as requested in #230 #234

Merged
merged 1 commit into from

2 participants

@notbenh

NOTES/POSSIBLE ISSUES:

  • the test is calling ::2 directly rather then latest. I was unsure on the going convention for a version specific change
  • I am not using alias to build the aliases. It seemed a bit heavy handed so I am using the old-style delegation.
ben hengst Adding the as_* methods as requested in #230
NOTES/POSSIBLE ISSUES:
  - the test is calling ::2 directly rather then latest.
    I was unsure on the going convention for a version specific change
  - I am not using alias to build the aliases.
    It seemed a bit heavy handed so I am using the old-style delegation.
89e8a05
@schwern schwern merged commit 99d95e3 into from
@schwern
Owner

I've begun some coding standards to address some of your questions and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 5, 2013
  1. Adding the as_* methods as requested in #230

    ben hengst authored
    NOTES/POSSIBLE ISSUES:
      - the test is calling ::2 directly rather then latest.
        I was unsure on the going convention for a version specific change
      - I am not using alias to build the aliases.
        It seemed a bit heavy handed so I am using the old-style delegation.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 2 deletions.
  1. +3 −2 lib/perl5i/2/Meta/Instance.pm
  2. +11 −0 t/dump/formats.t
View
5 lib/perl5i/2/Meta/Instance.pm
@@ -138,7 +138,7 @@ sub is_equal {
return perl5i::2::equal::are_equal($$$self, $other);
}
-
+sub as_perl{shift->perl(@_)}
sub perl {
require Data::Dumper;
@@ -173,7 +173,7 @@ sub dump {
return $self->$dumper(%args);
}
-
+sub as_json { shift->_dump_as_json(@_)}
sub _dump_as_json {
require JSON;
my $json = JSON->new
@@ -198,6 +198,7 @@ sub _dump_as_json {
return $json->encode(${${$_[0]}});
}
+sub as_yaml { shift->_dump_as_yaml(@_)}
sub _dump_as_yaml {
require YAML::Any;
return YAML::Any::Dump(${${$_[0]}});
View
11 t/dump/formats.t
@@ -0,0 +1,11 @@
+#!perl -w
+
+use perl5i::2; # I did not see any testing README for how to introduce a
+ # version specific change? Is everything expected to be latest?
+use Test::More tests => 3;
+
+my $ref = [1..10];
+
+is_deeply $ref->mo->as_perl, $ref->mo->perl, 'perl';
+is_deeply $ref->mo->as_json, $ref->mo->dump(format=>'json'), 'json';
+is_deeply $ref->mo->as_yaml, $ref->mo->dump(format=>'yaml'), 'yaml';
Something went wrong with that request. Please try again.