From: Dave Rolsky Date: Tue, 17 Mar 2009 15:57:44 +0000 (-0500) Subject: Make all the generate_* methods in CMOP::Accessor private. X-Git-Tag: 0.80_01~33 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=afc92ac600289dd8a31b1c4c0a5aa946a2022f1b;p=gitmo%2FClass-MOP.git Make all the generate_* methods in CMOP::Accessor private. --- diff --git a/examples/AttributesWithHistory.pod b/examples/AttributesWithHistory.pod index 54fcdc4..e7ae1c2 100644 --- a/examples/AttributesWithHistory.pod +++ b/examples/AttributesWithHistory.pod @@ -47,7 +47,7 @@ use base 'Class::MOP::Method::Accessor'; # generate the methods -sub generate_history_accessor_method { +sub _generate_history_accessor_method { my $attr_name = (shift)->associated_attribute->name; eval qq{sub { unless (ref \$_[0]->meta->get_attribute('$attr_name')->_history()->\{\$_[0]\}) \{ @@ -57,7 +57,7 @@ sub generate_history_accessor_method { }}; } -sub generate_accessor_method { +sub _generate_accessor_method { my $attr_name = (shift)->associated_attribute->name; eval qq{sub { if (scalar(\@_) == 2) { @@ -71,7 +71,7 @@ sub generate_accessor_method { }}; } -sub generate_writer_method { +sub _generate_writer_method { my $attr_name = (shift)->associated_attribute->name; eval qq{sub { unless (ref \$_[0]->meta->get_attribute('$attr_name')->_history()->\{\$_[0]\}) \{ diff --git a/examples/InsideOutClass.pod b/examples/InsideOutClass.pod index b69c10f..07da94f 100644 --- a/examples/InsideOutClass.pod +++ b/examples/InsideOutClass.pod @@ -45,7 +45,7 @@ use base 'Class::MOP::Method::Accessor'; ## Method generation helpers -sub generate_accessor_method { +sub _generate_accessor_method { my $attr = (shift)->associated_attribute; my $meta_class = $attr->associated_class; my $attr_name = $attr->name; @@ -56,7 +56,7 @@ sub generate_accessor_method { }; } -sub generate_reader_method { +sub _generate_reader_method { my $attr = (shift)->associated_attribute; my $meta_class = $attr->associated_class; my $attr_name = $attr->name; @@ -67,7 +67,7 @@ sub generate_reader_method { }; } -sub generate_writer_method { +sub _generate_writer_method { my $attr = (shift)->associated_attribute; my $meta_class = $attr->associated_class; my $attr_name = $attr->name; @@ -77,7 +77,7 @@ sub generate_writer_method { }; } -sub generate_predicate_method { +sub _generate_predicate_method { my $attr = (shift)->associated_attribute; my $meta_class = $attr->associated_class; my $attr_name = $attr->name; diff --git a/examples/LazyClass.pod b/examples/LazyClass.pod index 262cd73..0c87b3a 100644 --- a/examples/LazyClass.pod +++ b/examples/LazyClass.pod @@ -38,7 +38,7 @@ our $VERSION = '0.01'; use base 'Class::MOP::Method::Accessor'; -sub generate_accessor_method { +sub _generate_accessor_method { my $attr = (shift)->associated_attribute; my $attr_name = $attr->name; @@ -59,7 +59,7 @@ sub generate_accessor_method { }; } -sub generate_reader_method { +sub _generate_reader_method { my $attr = (shift)->associated_attribute; my $attr_name = $attr->name; diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index dcf5f32..27fe19f 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -67,7 +67,7 @@ sub _initialize_body { my $self = shift; my $method_name = join "_" => ( - 'generate', + '_generate', $self->accessor_type, 'method', ($self->is_inline ? 'inline' : ()) @@ -80,6 +80,12 @@ sub _initialize_body { ## generators sub generate_accessor_method { + warn 'The generate_accessor_method method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_accessor_method; +} + +sub _generate_accessor_method { my $attr = (shift)->associated_attribute; return sub { $attr->set_value($_[0], $_[1]) if scalar(@_) == 2; @@ -88,6 +94,12 @@ sub generate_accessor_method { } sub generate_reader_method { + warn 'The generate_reader_method method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_reader_method; +} + +sub _generate_reader_method { my $attr = (shift)->associated_attribute; return sub { confess "Cannot assign a value to a read-only accessor" if @_ > 1; @@ -96,6 +108,12 @@ sub generate_reader_method { } sub generate_writer_method { + warn 'The generate_writer_method method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_writer_method; +} + +sub _generate_writer_method { my $attr = (shift)->associated_attribute; return sub { $attr->set_value($_[0], $_[1]); @@ -103,6 +121,12 @@ sub generate_writer_method { } sub generate_predicate_method { + warn 'The generate_predicate_method method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_predicate_method; +} + +sub _generate_predicate_method { my $attr = (shift)->associated_attribute; return sub { $attr->has_value($_[0]) @@ -110,6 +134,12 @@ sub generate_predicate_method { } sub generate_clearer_method { + warn 'The generate_clearer_method method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_clearer_method; +} + +sub _generate_clearer_method { my $attr = (shift)->associated_attribute; return sub { $attr->clear_value($_[0]) @@ -118,8 +148,13 @@ sub generate_clearer_method { ## Inline methods - sub generate_accessor_method_inline { + warn 'The generate_accessor_method_inline method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_accessor_method_inline; +} + +sub _generate_accessor_method_inline { my $self = shift; my $attr = $self->associated_attribute; my $attr_name = $attr->name; @@ -139,6 +174,12 @@ sub generate_accessor_method_inline { } sub generate_reader_method_inline { + warn 'The generate_reader_method_inline method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_reader_method_inline; +} + +sub _generate_reader_method_inline { my $self = shift; my $attr = $self->associated_attribute; my $attr_name = $attr->name; @@ -157,6 +198,12 @@ sub generate_reader_method_inline { } sub generate_writer_method_inline { + warn 'The generate_writer_method_inline method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_writer_method_inline; +} + +sub _generate_writer_method_inline { my $self = shift; my $attr = $self->associated_attribute; my $attr_name = $attr->name; @@ -173,8 +220,13 @@ sub generate_writer_method_inline { return $code; } - sub generate_predicate_method_inline { + warn 'The generate_predicate_method_inline method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_predicate_method_inline; +} + +sub _generate_predicate_method_inline { my $self = shift; my $attr = $self->associated_attribute; my $attr_name = $attr->name; @@ -192,6 +244,12 @@ sub generate_predicate_method_inline { } sub generate_clearer_method_inline { + warn 'The generate_clearer_method_inline method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_generate_clearer_method_inline; +} + +sub _generate_clearer_method_inline { my $self = shift; my $attr = $self->associated_attribute; my $attr_name = $attr->name;