From 022152630a9084fbc604f0d06b0005d97747b50d Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Thu, 7 Nov 2013 11:32:13 +0000 Subject: migrate to Moo: forecast client --- lib/WebService/ForecastIo/DataPoint.pm | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'lib/WebService/ForecastIo/DataPoint.pm') diff --git a/lib/WebService/ForecastIo/DataPoint.pm b/lib/WebService/ForecastIo/DataPoint.pm index ba06fa1..47ef659 100644 --- a/lib/WebService/ForecastIo/DataPoint.pm +++ b/lib/WebService/ForecastIo/DataPoint.pm @@ -1,35 +1,21 @@ package WebService::ForecastIo::DataPoint; -use Moose; -use Moose::Util::TypeConstraints; -use MooseX::Types::DateTime; - -class_type 'WebService::ForecastIo::DataPoint'; - -subtype 'WebService::ForecastIo::DataPointArray', - as 'ArrayRef[WebService::ForecastIo::DataPoint]'; - -coerce 'WebService::ForecastIo::DataPoint', from 'HashRef', - via { WebService::ForecastIo::DataPoint->new($_) }; - -coerce 'WebService::ForecastIo::DataPointArray', from 'ArrayRef[HashRef]', - via { - my $array = $_; - [ map { WebService::ForecastIo::DataPoint->new($_) } - @$array ] - }; +use Moo; +use namespace::autoclean; +use Types::DateTime 'DateTimeT'; +use Types::Standard -all; has [qw( time sunriseTime sunsetTime precipIntensityMaxTime temperatureMinTime temperatureMaxTime )] => ( is => 'ro', - isa => 'DateTime', - coerce => 1, + isa => DateTimeT, + coerce => DateTimeT->coercion, ); has [qw(summary icon precipType)] => ( is => 'ro', - isa => 'Str', + isa => Str, ); has [qw( precipIntensity precipIntensityMax @@ -40,7 +26,7 @@ has [qw( precipIntensity precipIntensityMax cloudCover pressure visibility ozone )] => ( is => 'ro', - isa => 'Num', + isa => Num, ); 1; -- cgit v1.2.3