From cb0e593bad1973d9ad301ea4c10daa8f3d12d5aa Mon Sep 17 00:00:00 2001 From: dakkar Date: Thu, 24 Mar 2011 22:21:33 +0000 Subject: broken first stab --- lib/DeWeave/EDO.pm | 27 +++++++++++++++++++++++++ lib/DeWeave/Global.pm | 19 +++++++++++++++++ lib/DeWeave/WBO.pm | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 lib/DeWeave/EDO.pm create mode 100644 lib/DeWeave/Global.pm create mode 100644 lib/DeWeave/WBO.pm diff --git a/lib/DeWeave/EDO.pm b/lib/DeWeave/EDO.pm new file mode 100644 index 0000000..29a9cee --- /dev/null +++ b/lib/DeWeave/EDO.pm @@ -0,0 +1,27 @@ +package DeWeave::EDO; +use Moose; +use namespace::autoclean; +use MooseX::Types::Moose qw(Int Str Num); +use JSON::Any; + +extends 'DeWeave::WBO'; + +has cyhpertext => ( + isa => Str, + required => 1, + is => 'ro', +); + +has IV => ( + isa => Str, + required => 1, + is => 'ro', +); + +has hmac => ( + isa => Str, + required => 1, + is => 'ro', +); + +1; diff --git a/lib/DeWeave/Global.pm b/lib/DeWeave/Global.pm new file mode 100644 index 0000000..9e36bad --- /dev/null +++ b/lib/DeWeave/Global.pm @@ -0,0 +1,19 @@ +package DeWeave::Global; +use Moose; +use namespace::autoclean; +use MooseX::Types::Moose qw(Int Str Num); + +extends 'DeWeave::WBO'; + +has storageVersion => ( + isa => Num, + required => 1, + is => 'ro', +); + +has syncID => ( + isa => Str, + required => 1, + is => 'ro', +); + diff --git a/lib/DeWeave/WBO.pm b/lib/DeWeave/WBO.pm new file mode 100644 index 0000000..db89581 --- /dev/null +++ b/lib/DeWeave/WBO.pm @@ -0,0 +1,56 @@ +package DeWeave::WBO; +use Moose; +use namespace::autoclean; +use MooseX::Types::Moose qw(Int Str Num); +use JSON::Any; +use Try::Tiny; + +has id => ( + isa => Str, + required => 1, + is => 'ro', +); + +has modified => ( + isa => Num, + required => 1, + is => 'ro', +); + +has sortindex => ( + isa => Num, + required => 1, + is => 'ro', +); + +has payload => ( + isa => Str, + required => 1, + is => 'ro', +); + +has ttl => ( + isa => Int, + required => 0, + is => 'ro', +); + +sub from_json { + my ($class,$json)=@_; + + my $j = JSON::Any->new; + + my $args = $j->decode($json); + if (exists $args->{payload}) { + try { + my $extra_args = $j->decode($args->{payload}); + + @$args{keys %$extra_args} = + values %$extra_args; + }; + } + + $class->new($args); +} + +1; -- cgit v1.2.3