sub construct_instance {
my ($class, %params) = @_;
- my $instance = $class->get_meta_instance->create_instance();
+ my $meta_instance = $class->get_meta_instance;
+ my $instance = $meta_instance->create_instance();
# initialize *ALL* attributes, including masked ones (as opposed to applicable)
foreach my $current_class ($class->class_precedence_list()) {
my $meta = $current_class->meta;
foreach my $attr_name ($meta->get_attribute_list()) {
my $attr = $meta->get_attribute($attr_name);
- $attr->initialize_instance_slot($instance, \%params);
+ $attr->initialize_instance_slot($meta_instance, $instance, \%params);
}
}
# alter the way parameters are specified
sub initialize_instance_slot {
- my ($self, $instance, $params) = @_;
+ my ($self, $meta_instance, $instance, $params) = @_;
# if the attr has an init_arg, use that, otherwise,
# use the attributes name itself as the init_arg
my $init_arg = $self->init_arg();
}
# now add this to the instance structure
- my $meta_instance = $self->associated_class->get_meta_instance;
- $meta_instance->set_slot_value_with_init( $instance, $self->slot_name, $val );
+ $meta_instance->set_slot_value($instance, $self->name, $val);
}
-# mangle the slot name to include the fully qualified attr
-sub slot_name {
- my $self = shift;
- $self->associated_class->name . "::" . $self->SUPER::slot_name;
+sub name {
+ my $self = shift;
+ return ($self->associated_class->name . '::' . $self->SUPER::name)
}
1;
Thanks to Yuval "nothingmuch" Kogman for the idea for this example.
-=head1 AUTHOR
+=head1 AUTHORS
Stevan Little E<lt>stevan@iinteractive.comE<gt>
+Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
+
=head1 COPYRIGHT AND LICENSE
Copyright 2006 by Infinity Interactive, Inc.