summary refs log tree commit diff
path: root/lib/MooseX/Privacy/Meta/Attribute/Private.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-19 15:08:47 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-19 15:08:47 +0200
commiteb479abeb1020be663c471e0df622c9f70f16f20 (patch)
treef55825f7984826d61530bf1d366033a547433c5d /lib/MooseX/Privacy/Meta/Attribute/Private.pm
parentnew role to generate attribute methods (diff)
downloadmoosex-privacy-eb479abeb1020be663c471e0df622c9f70f16f20.tar.gz
use new role to generate method
Diffstat (limited to 'lib/MooseX/Privacy/Meta/Attribute/Private.pm')
-rw-r--r--lib/MooseX/Privacy/Meta/Attribute/Private.pm24
1 files changed, 6 insertions, 18 deletions
diff --git a/lib/MooseX/Privacy/Meta/Attribute/Private.pm b/lib/MooseX/Privacy/Meta/Attribute/Private.pm
index 241c6fb..b3c7a35 100644
--- a/lib/MooseX/Privacy/Meta/Attribute/Private.pm
+++ b/lib/MooseX/Privacy/Meta/Attribute/Private.pm
@@ -3,24 +3,12 @@ package MooseX::Privacy::Meta::Attribute::Private;
 use Moose::Role;
 use Carp qw/confess/;
 
-sub _generate_accessor_method {
-    my $self = shift;
-    my $attr = $self->associated_attribute;
-
-    my $package_name = $attr->associated_class->name;
-    my $class = $attr->associated_class->name->meta;
-    if ( $class->meta->has_attribute('local_private_attributes') ) {
-        $class->_push_private_attribute( $attr->name );
-    }
-
-    return sub {
-        my $self   = shift;
-        my $caller = ( scalar caller() );
-        confess "Attribute " . $attr->name . " is private"
-            unless $caller eq $package_name;
-        $attr->set_value( $self, $_[0] ) if scalar @_;;
-        $attr->get_value($self);
-    };
+with 'MooseX::Privacy::Meta::Attribute::Privacy' => {level => 'private'};
+
+sub _check_private {
+    my ($meta, $caller, $attr_name, $package_name) = @_;
+    confess "Attribute " . $attr_name . " is private"
+        unless $caller eq $package_name;
 }
 
 1;