How to do it - lazy building
file: code/LazyBuild/FindNewSeries.pm 12: has 'ua' => ( 13: is => 'ro', 14: required => 1, 15: isa => duck_type( [qw(get)] ), 16: lazy_build => 1, 17: ); 18: sub _build_ua { 19: return LWP::UserAgent->new( 20: agent => 'domms new series finder', 21: timeout => 5, 22: ); 23: }
and a _build_ method
ua
when initating the FindNewSeries
object, Moose will build a new UserAgent for us.