my $params = @_ == 1 ? $_[0] : {@_};
my $meta_instance = $class->get_meta_instance();
my $instance = $meta_instance->create_instance();
- foreach my $attr ($class->compute_all_applicable_attributes()) {
+ foreach my $attr ($class->get_all_attributes()) {
$attr->initialize_instance_slot($meta_instance, $instance, $params);
}
# NOTE:
my $instance = $self->instance_metaclass->new(
associated_metaclass => $self,
- attributes => [ $self->compute_all_applicable_attributes() ],
+ attributes => [ $self->get_all_attributes() ],
);
$self->add_meta_instance_dependencies()
|| confess "You can only clone instances, ($instance) is not a blessed instance";
my $meta_instance = $class->get_meta_instance();
my $clone = $meta_instance->clone_instance($instance);
- foreach my $attr ($class->compute_all_applicable_attributes()) {
+ foreach my $attr ($class->get_all_attributes()) {
if ( defined( my $init_arg = $attr->init_arg ) ) {
if (exists $params{$init_arg}) {
$attr->set_value($clone, $params{$init_arg});
# we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
$meta_instance->rebless_instance_structure($_[1], $self);
- foreach my $attr ( $self->compute_all_applicable_attributes ) {
+ foreach my $attr ( $self->get_all_attributes ) {
if ( $attr->has_value($instance) ) {
if ( defined( my $init_arg = $attr->init_arg ) ) {
$params{$init_arg} = $attr->get_value($instance)
}
}
- foreach my $attr ($self->compute_all_applicable_attributes) {
+ foreach my $attr ($self->get_all_attributes) {
$attr->initialize_instance_slot($meta_instance, $instance, \%params);
}
$self->remove_meta_instance_dependencies;
- my @attrs = $self->compute_all_applicable_attributes();
+ my @attrs = $self->get_all_attributes();
my %seen;
my @classes = grep { not $seen{$_->name}++ } map { $_->associated_class } @attrs;
}
sub get_all_attributes {
- shift->compute_all_applicable_attributes(@_);
-}
-
-sub compute_all_applicable_attributes {
my $self = shift;
my %attrs = map { %{ $self->initialize($_)->get_attribute_map } } reverse $self->linearized_isa;
return values %attrs;
}
+sub compute_all_applicable_attributes {
+ warn 'The construct_class_instance method has been deprecated.'
+ . " Use get_all_attributes instead.\n";
+
+ shift->get_all_attributes;
+}
+
sub find_attribute_by_name {
my ($self, $attr_name) = @_;
foreach my $class ($self->linearized_isa) {
This will traverse the inheritance hierarchy and return a list of all
the L<Class::MOP::Attribute> objects for this class and its parents.
-This method can also be called as C<compute_all_applicable_attributes>.
-
=item B<< $metaclass->find_attribute_by_name($attribute_name) >>
This will return a L<Class::MOP::Attribute> for the specified
sub attributes {
warn 'The attributes method is deprecated.'
- . " Use ->associated_metaclass->compute_all_applicable_attributes instead.\n";
+ . " Use ->associated_metaclass->get_all_attributes instead.\n";
my $self = shift;
- $self->{'attributes'} ||= [ $self->associated_metaclass->compute_all_applicable_attributes ]
+ $self->{'attributes'} ||= [ $self->associated_metaclass->get_all_attributes ]
}
## method
$source .= "\n" . 'my $instance = ' . $self->_meta_instance->inline_create_instance('$class');
$source .= ";\n" . (join ";\n" => map {
$self->_generate_slot_initializer($_, $close_over)
- } $self->associated_metaclass->compute_all_applicable_attributes);
+ } $self->associated_metaclass->get_all_attributes);
$source .= ";\n" . 'return $instance';
$source .= ";\n" . '}';
warn $source if $self->options->{debug};
is($meta->find_attribute_by_name('$foo'), $FOO_ATTR, '... got the right attribute for "foo"');
is_deeply(
- [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[
$BAR_ATTR,
$BAZ_ATTR,
'... got the right list of applicable attributes for Baz');
is_deeply(
- [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[ Bar->meta, Baz->meta, Foo->meta ],
'... got the right list of associated classes from the applicable attributes for Baz');
ok(!$meta->has_method('set_baz'), '... a writer has been removed');
is_deeply(
- [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[
$BAR_ATTR,
$FOO_ATTR,
'... got the right list of applicable attributes for Baz');
is_deeply(
- [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[ Bar->meta, Foo->meta ],
'... got the right list of associated classes from the applicable attributes for Baz');
}
is_deeply(
- [ sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[
$BAR_ATTR_2,
$FOO_ATTR,
'... got the right list of applicable attributes for Baz');
is_deeply(
- [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->compute_all_applicable_attributes() ],
+ [ map { $_->associated_class } sort { $a->name cmp $b->name } $meta->get_all_attributes() ],
[ Foo->meta, Foo->meta ],
'... got the right list of associated classes from the applicable attributes for Baz');
my @attributes;
lives_ok {
- @attributes = $meta->compute_all_applicable_attributes;
+ @attributes = $meta->get_all_attributes;
}
'... got the attribute list okay';
is_deeply(
my @attributes;
lives_ok {
- @attributes = $meta->compute_all_applicable_attributes;
+ @attributes = $meta->get_all_attributes;
}
'... got the attribute list okay';
is_deeply(
my @attributes;
lives_ok {
- @attributes = $meta->compute_all_applicable_attributes;
+ @attributes = $meta->get_all_attributes;
}
'... got the attribute list okay';
is_deeply(
sub mymetaclass_attributes{
my $self = shift;
return grep { $_->isa("MyMetaClass::Attribute") }
- $self->compute_all_applicable_attributes;
+ $self->get_all_attributes;
}
1;
'Class::MOP::Class' => [
# deprecated
'alias_method',
+ 'compute_all_applicable_attributes',
'compute_all_applicable_methods',
# unfinished feature
'update_package_cache_flag',
'wrap_method_body',
- # doc'd under get_all_attributes
- 'compute_all_applicable_attributes',
-
],
'Class::MOP::Instance' => [