From: Dave Rolsky Date: Sat, 14 Mar 2009 17:37:54 +0000 (-0500) Subject: make process_accessors private X-Git-Tag: 0.78_01~49 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=45a183fb2121b112e516532a4d72edb042966580;p=gitmo%2FClass-MOP.git make process_accessors private --- diff --git a/Changes b/Changes index f7b7c12..9d15d85 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,11 @@ Revision history for Perl extension Class-MOP. in (at least) 5.8.8. We now use $_[1] directly which seems to set the magic properly. (Sartak) + * Class::MOP::Attribute + - The process_accessors method is now private. A public alias + exists (and will stick around for a few releases), but it + warns that calling the public method is deprecated. + * MOP.xs - Stop is_class_loaded from thinking a class is loaded if it only has an empty GV (Florian Ragwitz). diff --git a/examples/AttributesWithHistory.pod b/examples/AttributesWithHistory.pod index 5d7ca19..54fcdc4 100644 --- a/examples/AttributesWithHistory.pod +++ b/examples/AttributesWithHistory.pod @@ -31,7 +31,7 @@ AttributesWithHistory->meta->add_after_method_modifier('install_accessors' => su my ($self) = @_; # and now add the history accessor $self->associated_class->add_method( - $self->process_accessors('history_accessor' => $self->history_accessor()) + $self->_process_accessors('history_accessor' => $self->history_accessor()) ) if $self->has_history_accessor(); }); diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index aaf2e1e..3c5e7a2 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -329,6 +329,11 @@ sub clear_value { sub accessor_metaclass { 'Class::MOP::Method::Accessor' } sub process_accessors { + warn "The process_accessors method has been made private and this public alias will be removed in a future release."; + goto &_process_accessors; +} + +sub _process_accessors { my ($self, $type, $accessor, $generate_as_inline_methods) = @_; my $method_ctx; @@ -384,23 +389,23 @@ sub install_accessors { my $class = $self->associated_class; $class->add_method( - $self->process_accessors('accessor' => $self->accessor(), $inline) + $self->_process_accessors('accessor' => $self->accessor(), $inline) ) if $self->has_accessor(); $class->add_method( - $self->process_accessors('reader' => $self->reader(), $inline) + $self->_process_accessors('reader' => $self->reader(), $inline) ) if $self->has_reader(); $class->add_method( - $self->process_accessors('writer' => $self->writer(), $inline) + $self->_process_accessors('writer' => $self->writer(), $inline) ) if $self->has_writer(); $class->add_method( - $self->process_accessors('predicate' => $self->predicate(), $inline) + $self->_process_accessors('predicate' => $self->predicate(), $inline) ) if $self->has_predicate(); $class->add_method( - $self->process_accessors('clearer' => $self->clearer(), $inline) + $self->_process_accessors('clearer' => $self->clearer(), $inline) ) if $self->has_clearer(); return; @@ -893,22 +898,6 @@ This method generates and installs code the attributes various accessors. It is typically called from the L C method. -This method will call C<< $attr->process_accessors >> for each of the -possible method types (accessor, reader, writer & predicate). - -=item B<< $attr->process_accessors($type, $value) >> - -This method takes a C<$type> (accessor, reader, writer or predicate), and -a C<$value> (the value passed into the constructor for each of the -different types). - -It will then either generate the method itself (using the -C methods listed below) or it will use the custom -method passed through the constructor. - -This method is mostly intended for internal use from the C<< -$attr->install_accessors >> method. - =item B<< $attr->remove_accessors >> This method removes all of the accessors associated with the diff --git a/t/014_attribute_introspection.t b/t/014_attribute_introspection.t index c8a4864..84fd2fd 100644 --- a/t/014_attribute_introspection.t +++ b/t/014_attribute_introspection.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 64; +use Test::More tests => 65; use Test::Exception; use Class::MOP; @@ -54,6 +54,7 @@ use Class::MOP; associate_method process_accessors + _process_accessors install_accessors remove_accessors diff --git a/t/021_attribute_errors_and_edge_cases.t b/t/021_attribute_errors_and_edge_cases.t index 9fa4705..4de3ff0 100644 --- a/t/021_attribute_errors_and_edge_cases.t +++ b/t/021_attribute_errors_and_edge_cases.t @@ -129,7 +129,7 @@ BEGIN {use Class::MOP;use Class::MOP::Attribute; my $attr = Class::MOP::Attribute->new('$test'); dies_ok { - $attr->process_accessors('fail', 'my_failing_sub'); + $attr->_process_accessors('fail', 'my_failing_sub'); } '... cannot find "fail" type generator'; }