— — — — — — |
has id => (
is => 'ro' ,
isa => 'Int' ,
default => -1,
);
has wanted => (
is => 'rw' ,
isa => boolean,
coerce => 1,
default => 1,
);
has priority => (
is => 'rw' ,
isa => number,
coerce => 1,
default => 0,
);
{
my %read = (
key => string,
length => number,
name => string,
bytesCompleted => number,
);
for my $camel ( keys %read ) {
my $name = __PACKAGE__->_camel2Normal( $camel );
has $name => (
is => 'ro' ,
isa => $read { $camel },
coerce => 1,
writer => "_set_$name" ,
);
}
}
sub BUILDARGS {
my $self = shift ;
my $args = $self ->SUPER::BUILDARGS( @_ );
for my $camel ( keys %$args ) {
my $key = __PACKAGE__->_camel2Normal( $camel );
$args ->{ $key } = delete $args ->{ $camel };
}
return $args ;
}
1;
|