Revision history for Perl extension Class-MOP.
+0.52
+ * Class::MOP::Class
+ - fixed bug in rebless_instance
+ (discovered by ash)
+
+ * Class::MOP::Method::Constructor
+ - removed assumptions about the existence of
+ a &meta method
+
0.51 Mon. Jan. 14, 2008
~~~ some misc. doc. fixes ~~~
~~ updated copyright dates ~~
use Class::MOP::Immutable;
BEGIN {
- our $VERSION = '0.51';
+ our $VERSION = '0.52';
our $AUTHORITY = 'cpan:STEVAN';
use XSLoader;
use Scalar::Util 'blessed', 'reftype', 'weaken';
use Sub::Name 'subname';
-our $VERSION = '0.26';
+our $VERSION = '0.27';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Module';
sub rebless_instance {
my ($self, $instance) = @_;
- my $old_metaclass = $instance->meta();
+
+ my $old_metaclass;
+ if ($instance->can('meta')) {
+ ($instance->meta->isa('Class::MOP::Class'))
+ || confess 'Cannot rebless instance if ->meta is not an instance of Class::MOP::Class';
+ $old_metaclass = $instance->meta;
+ }
+ else {
+ $old_metaclass = $self->initialize(blessed($instance));
+ }
+
my $meta_instance = $self->get_meta_instance();
$self->name->isa($old_metaclass->name)
use Carp 'confess';
use Scalar::Util 'blessed', 'weaken', 'looks_like_number';
-our $VERSION = '0.02';
+our $VERSION = '0.03';
our $AUTHORITY = 'cpan:STEVAN';
use base 'Class::MOP::Method::Generated';
}
sub generate_constructor_method {
- return sub { (shift)->meta->new_object(@_) }
+ return sub { Class::MOP::Class->initialize(shift)->new_object(@_) }
}
sub generate_constructor_method_inline {
my $source = 'sub {';
$source .= "\n" . 'my ($class, %params) = @_;';
- $source .= "\n" . 'return $class->meta->new_object(%params)';
+ $source .= "\n" . 'return Class::MOP::Class->initialize($class)->new_object(%params)';
$source .= "\n" . ' if $class ne \'' . $self->associated_metaclass->name . '\';';
$source .= "\n" . 'my $instance = ' . $self->meta_instance->inline_create_instance('$class');