summaryrefslogtreecommitdiff
path: root/lib/DeWeave/WBO.pm
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2011-03-26 12:40:12 +0000
committerdakkar <dakkar@thenautilus.net>2011-03-26 12:40:12 +0000
commitb398c46825dc73ac92677893dd2a714cd21f8a4d (patch)
tree6842b365f072b6fd761e5044be1093791584d6bb /lib/DeWeave/WBO.pm
parentcrypto works! (diff)
downloadDeWeave-b398c46825dc73ac92677893dd2a714cd21f8a4d.tar.gz
DeWeave-b398c46825dc73ac92677893dd2a714cd21f8a4d.tar.bz2
DeWeave-b398c46825dc73ac92677893dd2a714cd21f8a4d.zip
collections working, subclasses, strings
Diffstat (limited to 'lib/DeWeave/WBO.pm')
-rw-r--r--lib/DeWeave/WBO.pm33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/DeWeave/WBO.pm b/lib/DeWeave/WBO.pm
index 8d8a1ba..56bc3e1 100644
--- a/lib/DeWeave/WBO.pm
+++ b/lib/DeWeave/WBO.pm
@@ -1,9 +1,10 @@
-package DeWeave::WBO;
+package DeWeave::WBO;{
use Moose;
use namespace::autoclean;
use MooseX::Types::Moose qw(Int Str Num);
use JSON::Any;
use Try::Tiny;
+use Data::Dump 'pp';
has id => (
isa => Str,
@@ -24,6 +25,7 @@ has sortindex => (
);
has payload => (
+ traits => ['WBOInternal'],
isa => Str,
required => 1,
is => 'ro',
@@ -66,5 +68,34 @@ around BUILDARGS => sub {
return $args;
};
+sub as_string {
+ my ($self) = @_;
+
+ my $meta = $self->meta;
+
+ my $str = '';
+
+ for my $attribute ( $meta->get_all_attributes ) {
+
+ next if $attribute->does('DeWeave::WBO::Meta::Attribute::Internal');
+ next unless $attribute->has_value($self);
+
+ my $reader = $attribute->get_read_method;
+ $str .= sprintf "%s -> %s\n",
+ $attribute->name,
+ pp ($self->$reader);
+ }
+
+ return $str;
+}
+}
+
+package DeWeave::WBO::Meta::Attribute::Internal;{
+use Moose::Role;
+}
+
+package Moose::Meta::Attribute::Custom::Trait::WBOInternal;{
+sub register_implementation { 'DeWeave::WBO::Meta::Attribute::Internal' }
+}
1;