[Bps-public-commit] GnuPG-Interface branch, master, updated. 0.47_02-7-g26c504d

Alex Vandiver alexmv at bestpractical.com
Thu Mar 13 12:08:47 EDT 2014


The branch, master has been updated
       via  26c504df5bf9ced3c3e503d196777dd19db4bf59 (commit)
      from  c5fc99ea7bbec08b50da2075f83429bbd0b72e16 (commit)

Summary of changes:
 lib/GnuPG/Options.pm    | 18 ++++++++++++------
 lib/GnuPG/PrimaryKey.pm |  8 +++++++-
 2 files changed, 19 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 26c504df5bf9ced3c3e503d196777dd19db4bf59
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Mar 13 12:03:59 2014 -0400

    Restore context-sensitive behavior of methods lost in 4ea11794
    
    The conversion from Any::Moose to Moo in 4ea11794 changed the API in an
    important way: several accessors which were previously marked auto_deref
    began returning arrayrefs in scalar context, as Moo does not support
    auto_deref.  This broke modules which relied on the methods returning
    arrays in list context.
    
    Restore the context-sensitive behavior by re-implementing auto_deref for
    accessors which used it.  This also reverts code which was adjusted in
    4ea11794 because of the loss of auto_deref.

diff --git a/lib/GnuPG/Options.pm b/lib/GnuPG/Options.pm
index 51f9a43..a7c4203 100644
--- a/lib/GnuPG/Options.pm
+++ b/lib/GnuPG/Options.pm
@@ -72,7 +72,8 @@ has $_ => (
 ) for SCALARS;
 
 for my $list (LISTS) {
-    has $list => (
+    my $ref = $list . "_ref";
+    has $ref => (
         handles_via => 'Array',
         is          => 'rw',
         lazy        => 1,
@@ -82,6 +83,11 @@ for my $list (LISTS) {
             "push_$list" => 'push',
         },
     );
+
+    __PACKAGE__->meta->add_method($list => sub {
+        my $self = shift;
+        return wantarray ? @{$self->$ref(@_)} : $self->$ref(@_);
+    });
 }
 
 sub BUILD {
@@ -110,7 +116,7 @@ sub get_args {
     return (
         $self->get_meta_args(),
         $self->get_option_args(),
-        @{$self->extra_args()},
+        $self->extra_args(),
     );
 }
 
@@ -147,8 +153,8 @@ sub get_option_args {
     push @args, '--command-fd', $self->command_fd()
         if defined $self->command_fd();
 
-    push @args, map { ( '--recipient',  $_ ) } @{$self->recipients};
-    push @args, map { ( '--encrypt-to', $_ ) } @{$self->encrypt_to};
+    push @args, map { ( '--recipient',  $_ ) } $self->recipients();
+    push @args, map { ( '--encrypt-to', $_ ) } $self->encrypt_to();
 
     return @args;
 }
@@ -172,9 +178,9 @@ sub get_meta_args {
         if $self->meta_signing_key();
 
     push @args,
-        map { ( '--recipient', $_ ) } @{$self->meta_recipients_key_ids};
+        map { ( '--recipient', $_ ) } $self->meta_recipients_key_ids();
     push @args,
-        map { ( '--recipient', $_->hex_id() ) } @{$self->meta_recipients_keys};
+        map { ( '--recipient', $_->hex_id() ) } $self->meta_recipients_keys();
 
     return @args;
 }
diff --git a/lib/GnuPG/PrimaryKey.pm b/lib/GnuPG/PrimaryKey.pm
index d3c745e..bc84349 100644
--- a/lib/GnuPG/PrimaryKey.pm
+++ b/lib/GnuPG/PrimaryKey.pm
@@ -21,7 +21,8 @@ use MooX::HandlesVia;
 BEGIN { extends qw( GnuPG::Key ) }
 
 for my $list (qw(user_ids subkeys user_attributes)) {
-    has $list => (
+    my $ref = $list . "_ref";
+    has $ref => (
         handles_via => 'Array',
         is          => 'rw',
         default     => sub { [] },
@@ -29,6 +30,11 @@ for my $list (qw(user_ids subkeys user_attributes)) {
             "push_$list" => 'push',
         },
     );
+
+    __PACKAGE__->meta->add_method($list => sub {
+        my $self = shift;
+        return wantarray ? @{$self->$ref(@_)} : $self->$ref(@_);
+    });
 }
 
 has $_ => (

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list