diff options
author | dakkar <dakkar@thenautilus.net> | 2013-05-16 22:06:09 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2013-05-16 22:06:09 +0100 |
commit | 9b724c2c7edc3c2805516fea7f584cdf0031d8ca (patch) | |
tree | 549dac74b5f47a0b7810b990007829e48252d925 /lib/WebService/ForecastIo/Response.pm | |
parent | "time" support (diff) | |
download | HomePanel-9b724c2c7edc3c2805516fea7f584cdf0031d8ca.tar.gz HomePanel-9b724c2c7edc3c2805516fea7f584cdf0031d8ca.tar.bz2 HomePanel-9b724c2c7edc3c2805516fea7f584cdf0031d8ca.zip |
modules for all response blocks
Diffstat (limited to 'lib/WebService/ForecastIo/Response.pm')
-rw-r--r-- | lib/WebService/ForecastIo/Response.pm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/lib/WebService/ForecastIo/Response.pm b/lib/WebService/ForecastIo/Response.pm new file mode 100644 index 0000000..e217c70 --- /dev/null +++ b/lib/WebService/ForecastIo/Response.pm @@ -0,0 +1,55 @@ +package WebService::ForecastIo::Response; +use Moose; +use WebService::ForecastIo::DataPoint; +use WebService::ForecastIo::DataBlock; +use WebService::ForecastIo::Alert; +use JSON; + +has 'currently' => ( + is => 'ro', + isa => 'WebService::ForecastIo::DataPoint', + coerce => 1, +); + +has [qw(daily hourly minutely)] => ( + is => 'ro', + isa => 'WebService::ForecastIo::DataBlock', + coerce => 1, +); + +has [qw(latitude longitude)] => ( + is => 'ro', + isa => 'Num', +); + +has timezone => ( + is => 'ro', + isa => 'Str', +); + +has offset => ( + is => 'ro', + isa => 'Num', +); + +has alerts => ( + is => 'ro', + isa => 'WebService::ForecastIo::AlertArray', + coerce => 1, +); + +has flags => ( + is => 'ro', + isa => 'HashRef', +); + +around BUILDARGS => sub { + my ($orig,$class,@args) = @_; + + if (@args==1 and !ref($args[0])) { + @args = decode_json($args[0]); + } + return $class->$orig(@args); +}; + +1; |