use strict;
use warnings;
+use Class::MOP::Immutable;
use Class::MOP::Instance;
use Class::MOP::Method::Wrapped;
sub is_immutable { 0 }
{
- use Class::MOP::Immutable;
-
- my $IMMUTABLE_META;
-
+ # NOTE:
+ # the immutable version of a
+ # particular metaclass is
+ # really class-level data so
+ # we don't want to regenerate
+ # it any more than we need to
+ my $IMMUTABLE_METACLASS;
sub make_immutable {
my ($self) = @_;
- $IMMUTABLE_META ||= Class::MOP::Immutable->new($self->meta, {
+ $IMMUTABLE_METACLASS ||= Class::MOP::Immutable->new($self, {
read_only => [qw/superclasses/],
cannot_call => [qw/
add_method
get_meta_instance => 'SCALAR',
get_method_map => 'SCALAR',
}
- })->create_immutable_metaclass;
-
- $IMMUTABLE_META->make_metaclass_immutable(@_);
+ });
+
+ $IMMUTABLE_METACLASS->make_metaclass_immutable(@_)
}
}
=item B<get_attribute_map>
-=item B<add_attribute ($attribute_name, $attribute_meta_object)>
+=item B<add_attribute ($attribute_meta_object | $attribute_name, %attribute_spec)>
-This stores a C<$attribute_meta_object> in the B<Class::MOP::Class>
-instance associated with the given class, and associates it with
-the C<$attribute_name>. Unlike methods, attributes within the MOP
-are stored as meta-information only. They will be used later to
-construct instances from (see C<construct_instance> above).
+This stores the C<$attribute_meta_object> (or creates one from the
+C<$attribute_name> and C<%attribute_spec>) in the B<Class::MOP::Class>
+instance associated with the given class. Unlike methods, attributes
+within the MOP are stored as meta-information only. They will be used
+later to construct instances from (see C<construct_instance> above).
More details about the attribute meta-objects can be found in the
L<Class::MOP::Attribute> or the L<Class::MOP/The Attribute protocol>
section.
=head1 COPYRIGHT AND LICENSE
-Copyright 2006 by Infinity Interactive, Inc.
+Copyright 2006, 2007 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>