CORE::shift @{$reader->($_[0])}
};
}
+
+sub clear : method {
+ my ($attr, $reader, $writer) = @_;
+ return sub {
+ @{$reader->($_[0])} = ()
+ };
+}
sub get : method {
my ($attr, $reader, $writer) = @_;
=item B<unshift>
+=item B<clear>
+
=back
=head1 BUGS
return sub { scalar keys %{$reader->($_[0])} ? 1 : 0 };
}
+sub clear : method {
+ my ($attr, $reader, $writer) = @_;
+ return sub { %{$reader->($_[0])} = () };
+}
+
sub delete : method {
my ($attr, $reader, $writer) = @_;
return sub { delete $reader->($_[0])->{$_[1]} };
=item B<empty>
+=item B<clear>
+
=item B<exists>
=item B<get>
'set' => 'set_option_at',
'count' => 'num_options',
'empty' => 'has_options',
+ 'clear' => 'clear_options',
}
);
}
get_option_at
set_option_at
num_options
+ clear_options
has_options
];
is($stuff->num_options, 5, '... got 5 options');
is($stuff->get_option_at(0), 20, '... get option at index 0');
+$stuff->clear_options;
+is_deeply( $stuff->options, [], "... clear options" );
+
## check some errors
dies_ok {
'set' => 'set_option_at',
'count' => 'num_options',
'empty' => 'has_options',
+ 'clear' => 'clear_options',
}, '... got the right provies mapping');
is($options->container_type, 'Int', '... got the right container type');
'get' => 'get_option',
'empty' => 'has_options',
'count' => 'num_options',
+ 'clear' => 'clear_options',
'delete' => 'delete_option',
}
);
has_options
num_options
delete_option
+ clear_options
];
ok(!$stuff->has_options, '... we have no options');
is($stuff->num_options, 1, '... we have 1 option(s)');
is_deeply($stuff->options, { foo => 'bar' }, '... got more options now');
+$stuff->clear_options;
+
+is_deeply($stuff->options, { }, "... cleared options" );
+
lives_ok {
Stuff->new(options => { foo => 'BAR' });
} '... good constructor params';