Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #377 from ilmari/as-hash-cleanup

as_hash cleanup
  • Loading branch information...
commit 88633a0920d1b6bd3468f69b8527e3228005c6bf 2 parents 36c7478 + acaf457
Michael G. Schwern schwern authored
Showing with 6 additions and 4 deletions.
  1. +2 −1  lib/TB2/CanAsHash.pm
  2. +4 −3 lib/TB2/History.pm
3  lib/TB2/CanAsHash.pm
View
@@ -2,6 +2,7 @@ package TB2::CanAsHash;
use TB2::Mouse ();
use TB2::Mouse::Role;
+use Scalar::Util ();
with 'TB2::CanTry';
@@ -47,7 +48,7 @@ sub as_hash {
next unless defined $val;
- $val = $val->as_hash if eval { $self->try( sub { $val->can("as_hash") } ) };
+ $val = $val->as_hash if defined Scalar::Util::blessed($val) && $val->can("as_hash");
$hash{$key} = $val if defined $val;
}
7 lib/TB2/History.pm
View
@@ -709,12 +709,13 @@ my @Keys_To_Add = qw(
can_succeed
test_was_successful
);
-sub keys_for_as_hash {
+around keys_for_as_hash => sub {
+ my $orig = shift;
my $self = shift;
- my @keys = grep { !$Keys_To_Remove{$_} } @{ $self->TB2::CanAsHash::keys_for_as_hash };
+ my @keys = grep { !$Keys_To_Remove{$_} } @{ $self->$orig };
return [ @keys, @Keys_To_Add ];
-}
+};
no TB2::Mouse;
Please sign in to comment.
Something went wrong with that request. Please try again.