use Carp 'confess';
-our $VERSION = '0.04';
+our $VERSION = '0.05';
use base 'Class::MOP::Attribute';
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
if ( exists $params->{$init_arg} ) {
my $val = $params->{$init_arg};
- $self->associated_class
- ->get_meta_instance
- ->set_slot_value($instance, $self->name, $val);
+ $meta_instance->set_slot_value($instance, $self->name, $val);
}
}
+sub accessor_metaclass { 'LazyClass::Method::Accessor' }
+
+package # hide the package from PAUSE
+ LazyClass::Method::Accessor;
+
+use strict;
+use warnings;
+
+use Carp 'confess';
+
+our $VERSION = '0.01';
+
+use base 'Class::MOP::Method::Accessor';
+
sub generate_accessor_method {
- my $attr = shift;
+ my $attr = (shift)->associated_attribute;
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->get_meta_instance;
}
sub generate_reader_method {
- my $attr = shift;
+ my $attr = (shift)->associated_attribute;
my $attr_name = $attr->name;
my $meta_instance = $attr->associated_class->get_meta_instance;
};
}
+package # hide the package from PAUSE
+ LazyClass::Instance;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+use base 'Class::MOP::Instance';
+
+sub initialize_all_slots {}
+
1;
__END__
package BinaryTree;
- use metaclass 'Class::MOP::Class' => (
- ':attribute_metaclass' => 'LazyClass::Attribute'
+ use metaclass (
+ ':attribute_metaclass' => 'LazyClass::Attribute',
+ ':instance_metaclass' => 'LazyClass::Instance',
);
BinaryTree->meta->add_attribute('$:node' => (
ideal for a class which has a large amount of attributes,
several of which are optional.
-=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.