By providing the C<Array> trait to the C<traits> parameter you signal to
Moose that you would like to use the set of Array helpers. Moose will then
- create C<add_item> and C<next_item> methods that "just work". Behind the
-create an C<add_item> and a C<next_item> method that "just works". Behind
-the scenes C<add_item> is something like
++create C<add_item> and C<next_item> method that "just works". Behind the
+scenes C<add_item> is something like
- sub add_item {
+ sub add_item {
my ($self, @items) = @_;
+
+ for my $item (@items) {
+ $Item_TC->validate($item);
+ }
+
push @{ $self->queue }, @items;
}
use Moose;
has request => (
- is => 'ro'
- isa => 'HTTP::Request',
+ is => 'ro'
+ isa => 'HTTP::Request',
handles => {
- set_user_agent => [ header => 'UserAgent'],
- }
+ set_user_agent => [ header => 'UserAgent' ],
+ },
)
- With this definition calling C<< $spider->set_user_agent('MyClient') >> will
- behind the scenes call
- C<< $spider->request->header('UserAgent', 'MyClient') >>.
-With this definition, calling C<$spider->set_user_agent('MyClient')> will
-behind the scenes call C<$spider->request->header('UserAgent', 'MyClient')>.
++With this definition, calling C<< $spider->set_user_agent('MyClient') >> will
++behind the scenes call C<< $spider->request->header('UserAgent', 'MyClient')>>.
=head1 MISSING ATTRIBUTES