Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change to override apply instead of get_method_map

  • Loading branch information...
commit 335f554736b191c2a83ee6004c6afdf70e4b6c21 1 parent d9af95f
@gbarr authored
Showing with 18 additions and 13 deletions.
  1. +4 −1 Changes
  2. +14 −12 lib/MooseX/Role/Restricted.pm
View
5 Changes
@@ -1,2 +1,5 @@
-0.01 -- Sun Mar 15 21:14:03 CDT 2009
+1.02 -- Fri Oct 16 08:54:18 CDT 2009
+ * Change to override apply instead of get_method_map
+
+1.01 -- Sun Mar 15 21:14:03 CDT 2009
* Updated minimum required version of Moose to be 0.72
View
26 lib/MooseX/Role/Restricted.pm
@@ -1,6 +1,6 @@
package MooseX::Role::Restricted;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
use Moose::Role;
use Moose::Exporter;
@@ -46,20 +46,22 @@ has 'public_private_map' => (
default => sub { +{} }
);
-sub get_method_map {
- my $self = shift;
- my $method_map = $self->SUPER::get_method_map(@_);
- my $pp_map = $self->public_private_map;
- keys %$method_map; # reset iter
- while (my ($method, $info) = each %$method_map) {
- next if $method eq 'meta'; # always public
-
- my $private = exists $pp_map->{$method} ? $pp_map->{$method} : ($method =~ /^_/);
- delete $method_map->{$method} if $private;
+sub apply {
+ my ($self, $other, %args) = @_;
+ my $pp_map = $self->public_private_map;
+ my @exclude = grep { exists $pp_map->{$_} ? $pp_map->{$_} : /^_/; } $self->get_method_list;
+ if (exists $args{excludes}) {
+ $args{excludes} = push @exclude,
+ (
+ ref $args{excludes} eq 'ARRAY'
+ ? @{$args{excludes}}
+ : $args{excludes}
+ );
}
- return $method_map;
+ $args{'excludes'} = \@exclude;
+ $self->SUPER::apply($other, %args);
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.