package MooseImmutable;
use Moose;
has foo => (is => 'rw');
- make_immutable();
+ metaclass->make_immutable();
}
{
package MooseImmutable::NoConstructor;
use Moose;
has foo => (is => 'rw');
- make_immutable(inline_constructor => 0);
+ metaclass->make_immutable(inline_constructor => 0);
}
{
package ClassAccessorFast;
make_immutable => sub {
my $class = $CALLER;
return subname 'Moose::make_immutable' => sub {
+ warn "Use of make_immutable() is deprecated, please use metaclass->make_immutable now\n";
$class->meta->make_immutable(@_);
};
},
$self->y(0);
}
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package Point3D;
use Moose;
$self->{z} = 0;
};
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $point = Point->new(x => 1, y => 2);
$self->balance($current_balance - $amount);
}
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package CheckingAccount;
use Moose;
}
};
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $savings_account = BankAccount->new(balance => 250);
$tree->parent($self) if defined $tree;
};
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $root = BinaryTree->new(node => 'root');
has 'state' => (is => 'rw', isa => 'USState');
has 'zip_code' => (is => 'rw', isa => 'USZipCode');
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package Company;
}
};
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package Person;
$self->last_name;
}
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package Employee;
super() . ', ' . $self->title
};
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $ii;
default => sub { HTTP::Headers->new }
);
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $r = Request->new;
sprintf '$%0.2f USD' => $self->amount
}
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
ok(US::Currency->does('Comparable'), '... US::Currency does Comparable');
#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+BEGIN {
+ use_ok('Moose');
+}
+
{
package Foo;
- use Test::More tests => 1;
use Moose;
- is( metaclass(), __PACKAGE__->meta,
- 'metaclass and __PACKAGE__->meta are the same' );
+ ::is( metaclass(), __PACKAGE__->meta, 'metaclass and __PACKAGE__->meta are the same' );
}
},
);
- make_immutable;
+ metaclass->make_immutable;
}
{
},
);
- make_immutable;
+ metaclass->make_immutable;
}
dies_ok {
sub boo { 'BarClass::boo' }
sub foo { 'BarClass::foo' } # << the role overrides this ...
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package FooClass;
sub goo { 'FooClass::goo' } # << overrides the one from the role ...
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}{
package FooBarClass;
return $class->meta->new_object('__INSTANCE__' => $super, @_);
}
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
package Bucket;
use metaclass 'Class::MOP::Class';
sub baz { 'Foo::baz' }
- make_immutable(debug => 0);
+ metaclass->make_immutable(debug => 0);
}
my $foo = Foo->new;
sub child { 1 }
- make_immutable;
+ metaclass->make_immutable;
}
is(blessed(Grandparent->new), "Grandparent", "got a Grandparent object out of Grandparent->new");