|| $class->construct_class_instance(package => $package_name, @_);
}
-sub reinitialize {
- my $class = shift;
- my $package_name = shift;
- (defined $package_name && $package_name && !blessed($package_name))
- || confess "You must pass a package name and it cannot be blessed";
- Class::MOP::remove_metaclass_by_name($package_name);
- $class->construct_class_instance('package' => $package_name, @_);
-}
-
# NOTE: (meta-circularity)
# this is a special form of &construct_instance
# (see below), which is used to construct class
This initializes and returns returns a B<Class::MOP::Class> object
for a given a C<$package_name>.
-=item B<reinitialize ($package_name, %options)>
-
-This removes the old metaclass, and creates a new one in it's place.
-Do B<not> use this unless you really know what you are doing, it could
-very easily make a very large mess of your program.
-
=item B<construct_class_instance (%options)>
This will construct an instance of B<Class::MOP::Class>, it is
my $package_name = shift;
# we hand-construct the class
# until we can bootstrap it
- return Class::MOP::get_metaclass_by_name($package_name) ||
- $class->_new({
- 'package' => $package_name,
- });
+ if ( my $meta = Class::MOP::get_metaclass_by_name($package_name) ) {
+ return $meta;
+ } else {
+ my $meta = $class->_new({
+ 'package' => $package_name,
+ });
+
+ Class::MOP::store_metaclass_by_name($package_name, $meta);
+
+ return $meta;
+ }
+}
+
+sub reinitialize {
+ my $class = shift;
+ my $package_name = shift;
+ (defined $package_name && $package_name && !blessed($package_name))
+ || confess "You must pass a package name and it cannot be blessed";
+ Class::MOP::remove_metaclass_by_name($package_name);
+ $class->initialize('package' => $package_name, @_);
}
sub _new {
This will initialize a Class::MOP::Package instance which represents
the package of C<$package_name>.
+=item B<reinitialize ($package_name, %options)>
+
+This removes the old metaclass, and creates a new one in it's place.
+Do B<not> use this unless you really know what you are doing, it could
+very easily make a very large mess of your program.
+
=item B<name>
This is a read-only attribute which returns the package name for the
my @class_mop_package_methods = qw(
_new
- initialize
+ initialize reinitialize
name
namespace
my @class_mop_class_methods = qw(
_new
- initialize reinitialize create
+ initialize create
update_package_cache_flag
reset_package_cache_flag