# operations on created instances
-sub initialize_all_slots {
- my ($self, $instance) = @_;
- foreach my $slot_name ($self->get_all_slots) {
- $self->initialize_slot($instance, $slot_name);
- }
-}
-
sub get_slot_value {
my ($self, $instance, $slot_name) = @_;
return $instance->{$slot_name};
$instance->{$slot_name} = undef;
}
+sub initialize_all_slots {
+ my ($self, $instance) = @_;
+ foreach my $slot_name ($self->get_all_slots) {
+ $self->initialize_slot($instance, $slot_name);
+ }
+}
+
sub is_slot_initialized {
my ($self, $instance, $slot_name, $value) = @_;
exists $instance->{$slot_name} ? 1 : 0;
}
-# inlinable operation snippets
-
-sub inline_get_slot_value {
- my ($self, $instance_var_name, $slot_name) = @_;
- return ($instance_var_name . '->{\'' . $slot_name . '\'}');
-}
-
-sub inline_set_slot_value {
- my ($self, $instance_var_name, $slot_name, $value_name) = @_;
- return ($self->inline_get_slot_value($instance_var_name, $slot_name) . ' = ' . $value_name);
-}
-
-sub inline_initialize_slot {
- my ($self, $instance_var_name, $slot_name) = @_;
- $self->inline_set_slot_value($instance_var_name, $slot_name, 'undef');
-}
-
-sub inline_is_slot_initialized {
- my ($self, $instance_var_name, $slot_name) = @_;
- return ('exists ' . $self->inline_get_slot_value($instance_var_name, $slot_name) . ' ? 1 : 0');
-}
-
1;
__END__
=item B<is_slot_initialized>
-=item B<inline_get_slot_value>
-
-=item B<inline_set_slot_value>
-
-=item B<inline_initialize_slot>
-
-=item B<inline_is_slot_initialized>
-
=back
=head2 Introspection
use strict;
use warnings;
-use Test::More tests => 25;
+use Test::More tests => 22;
use Test::Exception;
BEGIN {
get_slot_value
set_slot_value
-
- inline_get_slot_value
- inline_set_slot_value
+ initialize_slot
+ initialize_all_slots
+ is_slot_initialized
/;
{
is($mi_foo->get_slot_value( $i_foo, "moosen" ), "the value", "... get slot value");
ok(!$i_foo->can('moosen'), '... Foo cant moosen');
-
-eval 'sub Foo::moosen { ' . $mi_foo->inline_get_slot_value( '$_[0]', 'moosen' ) . ' }';
-ok(!$@, "compilation of inline get value had no error");
-
-can_ok($i_foo, 'moosen');
-
-is($i_foo->moosen, "the value", "... inline get value worked");
-
-$mi_foo->set_slot_value( $i_foo, "moosen", "the other value" );
-
-is($i_foo->moosen, "the other value", "... inline get value worked (even after value is changed)");