diff options
Diffstat (limited to 'lib/WebService/ForecastIo/Alert.pm')
-rw-r--r-- | lib/WebService/ForecastIo/Alert.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/WebService/ForecastIo/Alert.pm b/lib/WebService/ForecastIo/Alert.pm new file mode 100644 index 0000000..37ff4ac --- /dev/null +++ b/lib/WebService/ForecastIo/Alert.pm @@ -0,0 +1,36 @@ +package WebService::ForecastIo::Alert; +use Moose; +use Moose::Util::TypeConstraints; +use MooseX::Types::URI 'Uri'; + +class_type 'WebService::ForecastIo::Alert'; + +subtype 'WebService::ForecastIo::AlertArray', + as 'ArrayRef[WebService::ForecastIo::Alert]'; + +coerce 'WebService::ForecastIo::Alert', from 'HashRef', + via { WebService::ForecastIo::Alert->new($_) }; + +coerce 'WebService::ForecastIo::AlertArray', from 'ArrayRef[HashRef]', + via { + my $array = $_; + [ map { WebService::ForecastIo::Alert->new($_) } + @$array ] + }; + +has title => ( + is => 'ro', + isa => 'Str', +); + +has expires => ( + is => 'ro', + isa => 'Int', # time! +); + +has uri => ( + is => 'ro', + isa => Uri, +); + +1; |