From: Dave Rolsky Date: Mon, 16 Mar 2009 04:59:19 +0000 (-0500) Subject: make construct_class_instance a private method X-Git-Tag: 0.80_01~53 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c0ad733aad955b32ae412728ef4ae0806216395;p=gitmo%2FClass-MOP.git make construct_class_instance a private method --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 6bc3e36..c4b3889 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -35,7 +35,13 @@ sub initialize { || confess "You must pass a package name and it cannot be blessed"; return Class::MOP::get_metaclass_by_name($package_name) - || $class->construct_class_instance(package => $package_name, @_); + || $class->_construct_class_instance(package => $package_name, @_); +} + +sub construct_class_instance { + warn 'The construct_class_instance method has been made private.' + . " The public version is deprecated and will be removed in a future release.\n"; + goto &_construct_class_instance; } # NOTE: (meta-circularity) @@ -44,7 +50,7 @@ sub initialize { # meta-object instances for any Class::MOP::* # class. All other classes will use the more # normal &construct_instance. -sub construct_class_instance { +sub _construct_class_instance { my $class = shift; my $options = @_ == 1 ? $_[0] : {@_}; my $package_name = $options->{package}; @@ -324,7 +330,7 @@ sub new_object { # Class::MOP::Class singletons here, so we # delegate this to &construct_class_instance # which will deal with the singletons - return $class->construct_class_instance(@_) + return $class->_construct_class_instance(@_) if $class->name->isa('Class::MOP::Class'); return $class->construct_instance(@_); } diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index 2fee9f8..3d21424 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 244; +use Test::More tests => 246; use Test::Exception; use Class::MOP; @@ -57,7 +57,9 @@ my @class_mop_class_methods = qw( instance_metaclass get_meta_instance create_meta_instance new_object clone_object - construct_instance construct_class_instance clone_instance + construct_instance + construct_class_instance _construct_class_instance + clone_instance rebless_instance check_metaclass_compatibility diff --git a/t/016_class_errors_and_edge_cases.t b/t/016_class_errors_and_edge_cases.t index 256d058..1626e0e 100644 --- a/t/016_class_errors_and_edge_cases.t +++ b/t/016_class_errors_and_edge_cases.t @@ -22,16 +22,16 @@ use Class::MOP; { dies_ok { - Class::MOP::Class->construct_class_instance(); - } '... construct_class_instance requires an :package parameter'; + Class::MOP::Class->_construct_class_instance(); + } '... _construct_class_instance requires an :package parameter'; dies_ok { - Class::MOP::Class->construct_class_instance(':package' => undef); - } '... construct_class_instance requires a defined :package parameter'; + Class::MOP::Class->_construct_class_instance(':package' => undef); + } '... _construct_class_instance requires a defined :package parameter'; dies_ok { - Class::MOP::Class->construct_class_instance(':package' => ''); - } '... construct_class_instance requires a valid :package parameter'; + Class::MOP::Class->_construct_class_instance(':package' => ''); + } '... _construct_class_instance requires a valid :package parameter'; }