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