Merge branch 'master' into renames-and-deprecations
Dave Rolsky [Sun, 5 Apr 2009 16:20:37 +0000 (11:20 -0500)]
Conflicts:
xt/pod_coverage.t

26 files changed:
examples/ArrayBasedStorage.pod
examples/AttributesWithHistory.pod
examples/InsideOutClass.pod
examples/InstanceCountingClass.pod
examples/LazyClass.pod
lib/Class/MOP/Attribute.pm
lib/Class/MOP/Class.pm
lib/Class/MOP/Instance.pm
lib/Class/MOP/Method/Accessor.pm
lib/Class/MOP/Method/Constructor.pm
lib/Class/MOP/Module.pm
t/003_methods.t
t/004_advanced_methods.t
t/005_attributes.t
t/010_self_introspection.t
t/011_create_class.t
t/013_add_attribute_alternate.t
t/016_class_errors_and_edge_cases.t
t/024_attribute_initializer.t
t/050_scala_style_mixin_composition.t
t/070_immutable_metaclass.t
t/072_immutable_w_constructors.t
t/073_make_mutable.t
t/106_LazyClass_test.t
t/lib/MyMetaClass.pm
xt/pod_coverage.t

index bff9baa..5c0369c 100644 (file)
@@ -23,7 +23,7 @@ sub new {
 
 sub create_instance {
     my $self = shift;
-    my $instance = $self->bless_instance_structure([]);
+    my $instance = bless [], $self->_class_name;
     $self->initialize_all_slots($instance);
     return $instance;
 }
index 54fcdc4..e7ae1c2 100644 (file)
@@ -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]\}) \{
index 5f94a25..07da94f 100644 (file)
@@ -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;
@@ -102,7 +102,7 @@ use base 'Class::MOP::Instance';
 
 sub create_instance {
        my ($self, $class) = @_;
-    $self->bless_instance_structure(\(my $instance));
+        bless \(my $instance), $self->_class_name;
 }
 
 sub get_slot_value {
index 3cf3eb3..b28fef8 100644 (file)
@@ -14,7 +14,7 @@ InstanceCountingClass->meta->add_attribute('count' => (
     default => 0
 ));
 
-InstanceCountingClass->meta->add_before_method_modifier('construct_instance' => sub {
+InstanceCountingClass->meta->add_before_method_modifier('_construct_instance' => sub {
     my ($class) = @_;
     $class->{'count'}++;       
 });
index 262cd73..0c87b3a 100644 (file)
@@ -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;
index e96b5cd..9579d7a 100644 (file)
@@ -331,7 +331,7 @@ sub accessor_metaclass { 'Class::MOP::Method::Accessor' }
 sub process_accessors {
     warn 'The process_accessors method has been made private.'
         . " The public version is deprecated and will be removed in a future release.\n";
-    goto &_process_accessors;
+    shift->_process_accessors;
 }
 
 sub _process_accessors {
@@ -501,7 +501,7 @@ This is a string value representing the expected key in an
 initialization hash. For instance, if we have an C<init_arg> value of
 C<-foo>, then the following code will Just Work.
 
-  MyClass->meta->construct_instance( -foo => 'Hello There' );
+  MyClass->meta->new_object( -foo => 'Hello There' );
 
 If an init_arg is not assigned, it will automatically use the
 attribute's name. If C<init_arg> is explicitly set to C<undef>, the
index ee4bcc7..eaa838d 100644 (file)
@@ -35,16 +35,22 @@ 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";
+    shift->_construct_class_instance;
 }
 
 # NOTE: (meta-circularity)
-# this is a special form of &construct_instance
+# this is a special form of _construct_instance
 # (see below), which is used to construct class
 # 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};
@@ -80,11 +86,11 @@ sub construct_class_instance {
         # it is safe to use meta here because
         # class will always be a subclass of
         # Class::MOP::Class, which defines meta
-        $meta = $class->meta->construct_instance($options)
+        $meta = $class->meta->_construct_instance($options)
     }
 
     # and check the metaclass compatibility
-    $meta->check_metaclass_compatibility();  
+    $meta->_check_metaclass_compatibility();  
 
     Class::MOP::store_metaclass_by_name($package_name, $meta);
 
@@ -146,7 +152,14 @@ sub update_package_cache_flag {
     $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);    
 }
 
+
 sub check_metaclass_compatibility {
+    warn 'The check_metaclass_compatibility method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_check_metaclass_compatibility;
+}
+
+sub _check_metaclass_compatibility {
     my $self = shift;
 
     # this is always okay ...
@@ -264,8 +277,6 @@ sub create {
         || confess "You must pass a HASH ref of methods"
             if exists $options{methods};                  
 
-    $class->SUPER::create(%options);
-
     my (%initialize_options) = @args;
     delete @initialize_options{qw(
         package
@@ -277,6 +288,8 @@ sub create {
     )};
     my $meta = $class->initialize( $package_name => %initialize_options );
 
+    $meta->_instantiate_module( $options{version}, $options{authority} );
+
     # FIXME totally lame
     $meta->add_method('meta' => sub {
         $class->initialize(ref($_[0]) || $_[0]);
@@ -324,17 +337,23 @@ 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(@_);
+    return $class->_construct_instance(@_);
 }
 
 sub construct_instance {
+    warn 'The construct_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_construct_instance;
+}
+
+sub _construct_instance {
     my $class = shift;
     my $params = @_ == 1 ? $_[0] : {@_};
     my $meta_instance = $class->get_meta_instance();
     my $instance = $meta_instance->create_instance();
-    foreach my $attr ($class->compute_all_applicable_attributes()) {
+    foreach my $attr ($class->get_all_attributes()) {
         $attr->initialize_instance_slot($meta_instance, $instance, $params);
     }
     # NOTE:
@@ -355,15 +374,21 @@ sub construct_instance {
 
 sub get_meta_instance {
     my $self = shift;
-    $self->{'_meta_instance'} ||= $self->create_meta_instance();
+    $self->{'_meta_instance'} ||= $self->_create_meta_instance();
 }
 
 sub create_meta_instance {
+    warn 'The create_meta_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_create_meta_instance;
+}
+
+sub _create_meta_instance {
     my $self = shift;
     
     my $instance = $self->instance_metaclass->new(
         associated_metaclass => $self,
-        attributes => [ $self->compute_all_applicable_attributes() ],
+        attributes => [ $self->get_all_attributes() ],
     );
 
     $self->add_meta_instance_dependencies()
@@ -383,16 +408,22 @@ sub clone_object {
     # Class::MOP::Class singletons here, they
     # should not be cloned.
     return $instance if $instance->isa('Class::MOP::Class');
-    $class->clone_instance($instance, @_);
+    $class->_clone_instance($instance, @_);
 }
 
 sub clone_instance {
+    warn 'The clone_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_clone_instance;
+}
+
+sub _clone_instance {
     my ($class, $instance, %params) = @_;
     (blessed($instance))
         || confess "You can only clone instances, ($instance) is not a blessed instance";
     my $meta_instance = $class->get_meta_instance();
     my $clone = $meta_instance->clone_instance($instance);
-    foreach my $attr ($class->compute_all_applicable_attributes()) {
+    foreach my $attr ($class->get_all_attributes()) {
         if ( defined( my $init_arg = $attr->init_arg ) ) {
             if (exists $params{$init_arg}) {
                 $attr->set_value($clone, $params{$init_arg});
@@ -420,7 +451,7 @@ sub rebless_instance {
     # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
     $meta_instance->rebless_instance_structure($_[1], $self);
 
-    foreach my $attr ( $self->compute_all_applicable_attributes ) {
+    foreach my $attr ( $self->get_all_attributes ) {
         if ( $attr->has_value($instance) ) {
             if ( defined( my $init_arg = $attr->init_arg ) ) {
                 $params{$init_arg} = $attr->get_value($instance)
@@ -432,7 +463,7 @@ sub rebless_instance {
         }
     }
 
-    foreach my $attr ($self->compute_all_applicable_attributes) {
+    foreach my $attr ($self->get_all_attributes) {
         $attr->initialize_instance_slot($meta_instance, $instance, \%params);
     }
     
@@ -466,7 +497,7 @@ sub superclasses {
         # not potentially creating an issues
         # we don't know about
 
-        $self->check_metaclass_compatibility();
+        $self->_check_metaclass_compatibility();
         $self->update_meta_instance_dependencies();
     }
     @{$self->get_package_symbol($var_spec)};
@@ -638,9 +669,9 @@ sub add_method {
 }
 
 sub alias_method {
-    my $self = shift;
+    warn "The alias_method method is deprecated. Use add_method instead.\n";
 
-    $self->add_method(@_);
+    shift->add_method;
 }
 
 sub has_method {
@@ -701,8 +732,10 @@ sub get_all_methods {
     return values %methods;
 }
 
-# compatibility
 sub compute_all_applicable_methods {
+    warn 'The compute_all_applicable_methods method is deprecated.'
+        . " Use get_all_methods instead.\n";
+
     return map {
         {
             name  => $_->name,
@@ -802,7 +835,7 @@ sub add_meta_instance_dependencies {
 
     $self->remove_meta_instance_dependencies;
 
-    my @attrs = $self->compute_all_applicable_attributes();
+    my @attrs = $self->get_all_attributes();
 
     my %seen;
     my @classes = grep { not $seen{$_->name}++ } map { $_->associated_class } @attrs;
@@ -887,15 +920,18 @@ sub get_attribute_list {
 }
 
 sub get_all_attributes {
-    shift->compute_all_applicable_attributes(@_);
-}
-
-sub compute_all_applicable_attributes {
     my $self = shift;
     my %attrs = map { %{ $self->initialize($_)->get_attribute_map } } reverse $self->linearized_isa;
     return values %attrs;
 }
 
+sub compute_all_applicable_attributes {
+    warn 'The construct_class_instance method has been deprecated.'
+        . " Use get_all_attributes instead.\n";
+
+    shift->get_all_attributes;
+}
+
 sub find_attribute_by_name {
     my ($self, $attr_name) = @_;
     foreach my $class ($self->linearized_isa) {
@@ -1423,8 +1459,6 @@ defined in this class.
 This will traverse the inheritance hierarchy and return a list of all
 the L<Class::MOP::Attribute> objects for this class and its parents.
 
-This method can also be called as C<compute_all_applicable_attributes>.
-
 =item B<< $metaclass->find_attribute_by_name($attribute_name) >>
 
 This will return a L<Class::MOP::Attribute> for the specified
index 885e17f..3683dcf 100644 (file)
@@ -75,6 +75,9 @@ sub create_instance {
 
 # for compatibility
 sub bless_instance_structure {
+    warn 'The bless_instance_structure method is deprecated.'
+        . " It will be removed in a future release.\n";
+
     my ($self, $instance_structure) = @_;
     bless $instance_structure, $self->_class_name;
 }
index e483cff..7b99469 100644 (file)
@@ -36,7 +36,7 @@ sub new {
     # needed
     weaken($self->{'attribute'});
 
-    $self->initialize_body;
+    $self->_initialize_body;
 
     return $self;
 }
@@ -58,10 +58,16 @@ sub accessor_type        { (shift)->{'accessor_type'} }
 ## factory
 
 sub initialize_body {
+    warn 'The initialize_body method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_initialize_body;
+}
+
+sub _initialize_body {
     my $self = shift;
 
     my $method_name = join "_" => (
-        'generate',
+        '_generate',
         $self->accessor_type,
         'method',
         ($self->is_inline ? 'inline' : ())
@@ -74,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";
+    shift->_generate_accessor_method;
+}
+
+sub _generate_accessor_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->set_value($_[0], $_[1]) if scalar(@_) == 2;
@@ -82,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";
+    shift->_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;
@@ -90,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";
+    shift->_generate_writer_method;
+}
+
+sub _generate_writer_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->set_value($_[0], $_[1]);
@@ -97,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";
+    shift->_generate_predicate_method;
+}
+
+sub _generate_predicate_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->has_value($_[0])
@@ -104,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";
+    shift->_generate_clearer_method;
+}
+
+sub _generate_clearer_method {
     my $attr = (shift)->associated_attribute;
     return sub {
         $attr->clear_value($_[0])
@@ -112,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";
+    shift->_generate_accessor_method_inline;
+}
+
+sub _generate_accessor_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -133,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";
+    shift->_generate_reader_method_inline;
+}
+
+sub _generate_reader_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -151,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";
+    shift->_generate_writer_method_inline;
+}
+
+sub _generate_writer_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -167,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";
+    shift->_generate_predicate_method_inline;
+}
+
+sub _generate_predicate_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
@@ -186,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";
+    shift->_generate_clearer_method_inline;
+}
+
+sub _generate_clearer_method_inline {
     my $self          = shift;
     my $attr          = $self->associated_attribute;
     my $attr_name     = $attr->name;
index eefea81..4358de9 100644 (file)
@@ -31,7 +31,7 @@ sub new {
     # needed
     weaken($self->{'associated_metaclass'});
 
-    $self->initialize_body;
+    $self->_initialize_body;
 
     return $self;
 }
@@ -62,20 +62,35 @@ sub associated_metaclass { (shift)->{'associated_metaclass'} }
 ## cached values ...
 
 sub meta_instance {
+    warn 'The meta_instance method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_meta_instance;
+}
+
+sub _meta_instance {
     my $self = shift;
     $self->{'meta_instance'} ||= $self->associated_metaclass->get_meta_instance;
 }
 
 sub attributes {
+    warn 'The attributes method is deprecated.'
+        . " Use ->associated_metaclass->get_all_attributes instead.\n";
+
     my $self = shift;
-    $self->{'attributes'} ||= [ $self->associated_metaclass->compute_all_applicable_attributes ]
+    $self->{'attributes'} ||= [ $self->associated_metaclass->get_all_attributes ]
 }
 
 ## method
 
 sub initialize_body {
+    warn 'The initialize_body method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_initialize_body;
+}
+
+sub _initialize_body {
     my $self        = shift;
-    my $method_name = 'generate_constructor_method';
+    my $method_name = '_generate_constructor_method';
 
     $method_name .= '_inline' if $self->is_inline;
 
@@ -83,10 +98,22 @@ sub initialize_body {
 }
 
 sub generate_constructor_method {
+    warn 'The generate_constructor_method method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_constructor_method;
+}
+
+sub _generate_constructor_method {
     return sub { Class::MOP::Class->initialize(shift)->new_object(@_) }
 }
 
 sub generate_constructor_method_inline {
+    warn 'The generate_constructor_method_inline method has been made private.'
+        . " The public version is deprecated and will be removed in a future release.\n";
+    shift->_generate_constructor_method_inline;
+}
+
+sub _generate_constructor_method_inline {
     my $self = shift;
 
     my $close_over = {};
@@ -99,10 +126,10 @@ sub generate_constructor_method_inline {
 
     $source .= "\n" . 'my $params = @_ == 1 ? $_[0] : {@_};';
 
-    $source .= "\n" . 'my $instance = ' . $self->meta_instance->inline_create_instance('$class');
+    $source .= "\n" . 'my $instance = ' . $self->_meta_instance->inline_create_instance('$class');
     $source .= ";\n" . (join ";\n" => map {
         $self->_generate_slot_initializer($_, $close_over)
-    } @{$self->attributes});
+    } $self->associated_metaclass->get_all_attributes);
     $source .= ";\n" . 'return $instance';
     $source .= ";\n" . '}';
     warn $source if $self->options->{debug};
@@ -148,12 +175,12 @@ sub _generate_slot_initializer {
     if ( defined $attr->init_arg ) {
       return (
           'if(exists $params->{\'' . $attr->init_arg . '\'}){' . "\n" .
-                $self->meta_instance->inline_set_slot_value(
+                $self->_meta_instance->inline_set_slot_value(
                     '$instance',
                     $attr->name,
                     '$params->{\'' . $attr->init_arg . '\'}' ) . "\n" .
            '} ' . (!defined $default ? '' : 'else {' . "\n" .
-                $self->meta_instance->inline_set_slot_value(
+                $self->_meta_instance->inline_set_slot_value(
                     '$instance',
                     $attr->name,
                      $default ) . "\n" .
@@ -161,7 +188,7 @@ sub _generate_slot_initializer {
         );
     } elsif ( defined $default ) {
         return (
-            $self->meta_instance->inline_set_slot_value(
+            $self->_meta_instance->inline_set_slot_value(
                 '$instance',
                 $attr->name,
                  $default ) . "\n"
index d43bfbd..579fbd4 100644 (file)
@@ -33,23 +33,25 @@ sub identifier {
 }
 
 sub create {
-    my ( $class, %options ) = @_;
+    confess "The Class::MOP::Module->create method has been made a private object method.\n";
+}
 
-    my $package_name = $options{package};
+sub _instantiate_module {
+    my $self      = shift;
+    my $version   = shift;
+    my $authority = shift;
 
-    (defined $package_name && $package_name)
-        || confess "You must pass a package name";
+    my $package_name = $self->name;
 
     my $code = "package $package_name;";
-    $code .= "\$$package_name\:\:VERSION = '" . $options{version} . "';"
-        if exists $options{version};
-    $code .= "\$$package_name\:\:AUTHORITY = '" . $options{authority} . "';"
-        if exists $options{authority};
+
+    $code .= "\$$package_name\:\:VERSION = '" . $version . "';"
+        if defined $version;
+    $code .= "\$$package_name\:\:AUTHORITY = '" . $authority . "';"
+        if defined $authority;
 
     eval $code;
     confess "creation of $package_name failed : $@" if $@;
-
-    return; # XXX: should this return some kind of meta object? ~sartak
 }
 
 1;
index 5088f50..e518c36 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 67;
+use Test::More tests => 65;
 use Test::Exception;
 
 use Scalar::Util qw/reftype/;
@@ -137,17 +137,6 @@ for my $method_name (qw/
     }
 }
 
-{
-    package Foo::Aliasing;
-    use metaclass;
-    sub alias_me { '...' }
-}
-
-$Foo->alias_method('alias_me' => Foo::Aliasing->meta->get_method('alias_me'));
-
-ok($Foo->has_method('alias_me'), '... Foo->has_method(alias_me) (aliased from Foo::Aliasing)');
-ok(defined &Foo::alias_me, '... Foo does have a symbol table slow for alias_me though');
-
 ok(!$Foo->has_method('blessed'), '... !Foo->has_method(blessed) (imported into Foo)');
 ok(!$Foo->has_method('boom'), '... !Foo->has_method(boom) (defined in main:: using symbol tables and Sub::Name w/out package name)');
 
@@ -156,7 +145,7 @@ is($Foo->get_method('not_a_real_method'), undef, '... Foo->get_method(not_a_real
 
 is_deeply(
     [ sort $Foo->get_method_list ],
-    [ qw(FOO_CONSTANT alias_me baaz bang bar baz blah cake evaled_foo floob foo pie) ],
+    [ qw(FOO_CONSTANT baaz bang bar baz blah cake evaled_foo floob foo pie) ],
     '... got the right method list for Foo');
 
 is_deeply(
@@ -164,7 +153,6 @@ is_deeply(
     [
         map { $Foo->get_method($_) } qw(
             FOO_CONSTANT
-            alias_me
             baaz            
             bang 
             bar 
@@ -186,7 +174,7 @@ dies_ok { Foo->foo } '... cannot call Foo->foo because it is not there';
 
 is_deeply(
     [ sort $Foo->get_method_list ],
-    [ qw(FOO_CONSTANT alias_me baaz bang bar baz blah cake evaled_foo floob pie) ],
+    [ qw(FOO_CONSTANT baaz bang bar baz blah cake evaled_foo floob pie) ],
     '... got the right method list for Foo');
 
 
@@ -224,7 +212,6 @@ is_deeply(
     [ sort { $a->name cmp $b->name } $Bar->get_all_methods() ],
     [
         $Foo->get_method('FOO_CONSTANT'),
-        $Foo->get_method('alias_me'),
         $Foo->get_method('baaz'),
         $Foo->get_method('bang'),
         $Bar->get_method('bar'),
index 792b353..f598382 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 12;
+use Test::More tests => 11;
 use Test::Exception;
 
 use Class::MOP;
@@ -106,38 +106,6 @@ is_deeply(
     ],
     '... got the right list of applicable methods for Foo::Bar');
 
-# test compute_all_applicable_methods once for compat
-is_deeply(
-    [ sort { $a->{name} cmp $b->{name} } Class::MOP::Class->initialize('Foo::Bar::Baz')->compute_all_applicable_methods() ],
-    [
-        {
-            name  => 'BUILD',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('BUILD')
-        },    
-        {
-            name  => 'bar',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('bar')
-        },
-        {
-            name  => 'baz',
-            class => 'Baz',
-            code  => Class::MOP::Class->initialize('Baz')->get_method('baz')
-        },        
-        {
-            name  => 'foo',
-            class => 'Foo',
-            code  => Class::MOP::Class->initialize('Foo')->get_method('foo')
-        },   
-        {
-            name  => 'foobarbaz',
-            class => 'Foo::Bar::Baz',
-            code  => Class::MOP::Class->initialize('Foo::Bar::Baz')->get_method('foobarbaz')
-        },            
-    ],
-    '... got the right list of applicable methods for Foo::Bar::Baz');
-
 ## find_all_methods_by_name
 
 is_deeply(
index dad4d54..1429a0a 100644 (file)
@@ -113,7 +113,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
     is($meta->find_attribute_by_name('$foo'), $FOO_ATTR, '... got the right attribute for "foo"');
 
     is_deeply(
-        [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+        [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
         [
             $BAR_ATTR,
             $BAZ_ATTR,
@@ -122,7 +122,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
         '... got the right list of applicable attributes for Baz');
 
     is_deeply(
-        [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+        [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
         [ Bar->meta, Baz->meta, Foo->meta ],
         '... got the right list of associated classes from the applicable attributes for Baz');
 
@@ -139,7 +139,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
     ok(!$meta->has_method('set_baz'), '... a writer has been removed');
 
     is_deeply(
-        [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+        [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
         [
             $BAR_ATTR,
             $FOO_ATTR,
@@ -147,7 +147,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
         '... got the right list of applicable attributes for Baz');
 
     is_deeply(
-        [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+        [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
         [ Bar->meta, Foo->meta ],
         '... got the right list of associated classes from the applicable attributes for Baz');
 
@@ -164,7 +164,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
      }
 
      is_deeply(
-         [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+         [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
          [
              $BAR_ATTR_2,
              $FOO_ATTR,
@@ -172,7 +172,7 @@ is($BAZ_ATTR->name, '$baz', '... got the attributes name correctly');
          '... got the right list of applicable attributes for Baz');
 
      is_deeply(
-         [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+         [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
          [ Foo->meta, Foo->meta ],
          '... got the right list of associated classes from the applicable attributes for Baz');
 
index b9b7e8b..1e35255 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 250;
+use Test::More tests => 262;
 use Test::Exception;
 
 use Class::MOP;
@@ -40,6 +40,8 @@ my @class_mop_package_methods = qw(
 my @class_mop_module_methods = qw(
     _new
 
+    _instantiate_module
+
     version authority identifier create
 );
 
@@ -55,11 +57,14 @@ my @class_mop_class_methods = qw(
 
     create_anon_class is_anon_class
 
-    instance_metaclass get_meta_instance create_meta_instance
+    instance_metaclass get_meta_instance
+    create_meta_instance _create_meta_instance
     new_object clone_object
-    construct_instance construct_class_instance clone_instance
+    construct_instance _construct_instance
+    construct_class_instance _construct_class_instance
+    clone_instance _clone_instance
     rebless_instance rebless_instance_away
-    check_metaclass_compatibility
+    check_metaclass_compatibility _check_metaclass_compatibility
 
     add_meta_instance_dependencies remove_meta_instance_dependencies update_meta_instance_dependencies
     add_dependent_meta_instance remove_dependent_meta_instance
index 839a8d9..a0f6fe3 100644 (file)
@@ -21,7 +21,7 @@ my $Point = Class::MOP::Class->create('Point' => (
     methods => {
         'new' => sub {
             my $class = shift;
-            my $instance = $class->meta->construct_instance(@_);
+            my $instance = $class->meta->new_object(@_);
             bless $instance => $class;
         },
         'clear' => sub {
index 1bb0f03..f133d3e 100644 (file)
@@ -22,7 +22,7 @@ use Class::MOP;
 
     sub new {
         my $class = shift;
-        bless $class->meta->construct_instance(@_) => $class;
+        bless $class->meta->new_object(@_) => $class;
     }
 
     sub clear {
index 256d058..df5fe2a 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 48;
+use Test::More tests => 43;
 use Test::Exception;
 
 use Class::MOP;
@@ -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'; 
 }
 
 
@@ -58,10 +58,6 @@ use Class::MOP;
     dies_ok {
         Class::MOP::Class->clone_object(1);
     } '... can only clone instances';
-    
-    dies_ok {
-        Class::MOP::Class->clone_instance(1);
-    } '... can only clone instances';    
 }
 
 {
@@ -84,24 +80,6 @@ use Class::MOP;
 
 {
     dies_ok {
-        Class::MOP::Class->alias_method();
-    } '... alias_method dies as expected';
-    
-    dies_ok {
-        Class::MOP::Class->alias_method('');
-    } '... alias_method dies as expected';   
-
-    dies_ok {
-        Class::MOP::Class->alias_method('foo' => 'foo');
-    } '... alias_method dies as expected';
-    
-    dies_ok {
-        Class::MOP::Class->alias_method('foo' => []);
-    } '... alias_method dies as expected';     
-}
-
-{
-    dies_ok {
         Class::MOP::Class->has_method();
     } '... has_method dies as expected';
     
index 46f6c31..328ff7c 100644 (file)
@@ -34,7 +34,7 @@ This checks that the initializer is used to set the initial value.
 can_ok('Foo', 'get_bar');
 can_ok('Foo', 'set_bar');    
 
-my $foo = Foo->meta->construct_instance(bar => 10);
+my $foo = Foo->meta->new_object(bar => 10);
 is($foo->get_bar, 20, "... initial argument was doubled as expected");
 
 $foo->set_bar(30);
index 7dcc949..2078494 100644 (file)
@@ -101,7 +101,7 @@ sub ::with ($) {
 
     # add all the methods in ....    
     foreach my $method_name (keys %methods) {
-        $metaclass->alias_method($method_name => $methods{$method_name}) 
+        $metaclass->add_method($method_name => $methods{$method_name}) 
             unless $metaclass->has_method($method_name);
     }    
 }
index 4ec34fc..2741363 100644 (file)
@@ -135,7 +135,7 @@ use Class::MOP;
 
     my @attributes;
     lives_ok {
-        @attributes = $meta->compute_all_applicable_attributes;
+        @attributes = $meta->get_all_attributes;
     }
     '... got the attribute list okay';
     is_deeply(
@@ -207,7 +207,7 @@ use Class::MOP;
 
     my @attributes;
     lives_ok {
-        @attributes = $meta->compute_all_applicable_attributes;
+        @attributes = $meta->get_all_attributes;
     }
     '... got the attribute list okay';
     is_deeply(
@@ -279,7 +279,7 @@ use Class::MOP;
 
     my @attributes;
     lives_ok {
-        @attributes = $meta->compute_all_applicable_attributes;
+        @attributes = $meta->get_all_attributes;
     }
     '... got the attribute list okay';
     is_deeply(
index abed7a7..7ef79f0 100644 (file)
@@ -228,14 +228,14 @@ BEGIN {use Class::MOP;use Class::MOP::Immutable;
     ok(!Baz->meta->has_method('new'), '... no constructor was made');
 
     {
-        my $baz = Baz->meta->construct_instance;
+        my $baz = Baz->meta->new_object;
         isa_ok($baz, 'Bar');
         is($baz->bar, 'BAR', '... got the right default value');
         is($baz->baz, 'BAZ', '... got the right default value');
     }
 
     {
-        my $baz = Baz->meta->construct_instance(bar => 'BAZ!', baz => 'BAR!', bah => 'BAH!');
+        my $baz = Baz->meta->new_object(bar => 'BAZ!', baz => 'BAR!', bah => 'BAH!');
         isa_ok($baz, 'Baz');
         is($baz->bar, 'BAZ!', '... got the right parameter value');
         is($baz->baz, 'BAR!', '... got the right parameter value');
index 1ad0c96..ae6210f 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 114;
+use Test::More tests => 101;
 use Test::Exception;
 
 use Scalar::Util;
@@ -72,13 +72,6 @@ use Class::MOP;
     ok( $meta->add_method('xyz', sub{'xxx'}), '... added method');
     is( Baz->xyz, 'xxx',                      '... method xyz works');
 
-    ok(! $meta->has_method('zxy')             ,'...  we dont have the aliased method yet');    
-    ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
-    ok( $meta->has_method('zxy')             ,'...  the aliased method does register');    
-    is( Baz->zxy, 'xxx',                      '... method zxy works');
-    ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
-
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok(Baz->can('fickle'),                '... Baz can fickle');
     ok($meta->remove_attribute('fickle'), '... removed attribute');
@@ -111,8 +104,6 @@ use Class::MOP;
     lives_ok { $meta->make_immutable() } '... changed Baz to be immutable';
 
     dies_ok{ $meta->add_method('xyz', sub{'xxx'})  } '... exception thrown as expected';
-    dies_ok{ $meta->alias_method('zxy',sub{'xxx'}) } '... exception thrown as expected';
-    dies_ok{ $meta->remove_method('zxy')           } '... exception thrown as expected';
 
     dies_ok {
       $meta->add_attribute('fickle', accessor => 'fickle')
@@ -137,8 +128,8 @@ use Class::MOP;
     my $meta = Baz->meta->create_anon_class(superclasses => ['Baz']);
     my %orig_keys = map { $_ => 1 } grep { !/^_/ } keys %$meta;
     $orig_keys{immutable_transformer} = 1;
-    my @orig_meths = sort { $a->{name} cmp $b->{name} }
-      $meta->compute_all_applicable_methods;
+    my @orig_meths = sort { $a->name cmp $b->name }
+      $meta->get_all_methods;
     ok($meta->is_anon_class,                  'We have an anon metaclass');
     ok($meta->is_mutable,  '... our anon class is mutable');
     ok(!$meta->is_immutable,  '... our anon class is not immutable');
@@ -161,19 +152,16 @@ use Class::MOP;
     my $instance = $meta->new_object;
 
     my %new_keys  = map { $_ => 1 } grep { !/^_/ } keys %$meta;
-    my @new_meths = sort { $a->{name} cmp $b->{name} }
-      $meta->compute_all_applicable_methods;
+    my @new_meths = sort { $a->name cmp $b->name }
+      $meta->get_all_methods;
     is_deeply(\%orig_keys, \%new_keys, '... no extraneous hashkeys');
-    is_deeply(\@orig_meths, \@new_meths, '... no extraneous methods');
+    is_deeply(\@orig_meths, \@new_meths, '... no straneous methods');
 
     isa_ok($meta, 'Class::MOP::Class', '... Anon class isa Class::MOP::Class');
 
     ok( $meta->add_method('xyz', sub{'xxx'}), '... added method');
     is( $instance->xyz , 'xxx',               '... method xyz works');
-    ok( $meta->alias_method('zxy',sub{'xxx'}),'... aliased method');
-    is( $instance->zxy, 'xxx',                '... method zxy works');
     ok( $meta->remove_method('xyz'),          '... removed method');
-    ok( $meta->remove_method('zxy'),          '... removed aliased method');
 
     ok($meta->add_attribute('fickle', accessor => 'fickle'), '... added attribute');
     ok($instance->can('fickle'),          '... instance can fickle');
@@ -211,8 +199,6 @@ use Class::MOP;
     lives_ok {$meta->make_immutable  } '... changed class to be immutable';
 
     dies_ok{ $meta->add_method('xyz', sub{'xxx'})  } '... exception thrown as expected';
-    dies_ok{ $meta->alias_method('zxy',sub{'xxx'}) } '... exception thrown as expected';
-    dies_ok{ $meta->remove_method('zxy')           } '... exception thrown as expected';
 
     dies_ok {
       $meta->add_attribute('fickle', accessor => 'fickle')
index a941c40..94c50fb 100644 (file)
@@ -33,7 +33,7 @@ BEGIN {use Class::MOP;
 
     sub new {
         my $class = shift;
-        bless $class->meta->construct_instance(@_) => $class;
+        bless $class->meta->new_object(@_) => $class;
     }
 }
 
index 0c060cd..b70fe14 100644 (file)
@@ -9,7 +9,7 @@ use base 'Class::MOP::Class';
 sub mymetaclass_attributes{
   my $self = shift;
   return grep { $_->isa("MyMetaClass::Attribute") }
-    $self->compute_all_applicable_attributes;
+    $self->get_all_attributes;
 }
 
 1;
index 81f5970..0897f59 100644 (file)
@@ -19,6 +19,7 @@ my %trustme = (
     'Class::MOP::Class'     => [
         # deprecated
         'alias_method',
+        'compute_all_applicable_attributes',
         'compute_all_applicable_methods',
 
         # unfinished feature
@@ -42,9 +43,6 @@ my %trustme = (
         'update_package_cache_flag',
         'wrap_method_body',
 
-        # doc'd under get_all_attributes
-        'compute_all_applicable_attributes',
-
         # doc'd with rebless_instance
         'rebless_instance_away',
     ],