Permalink
Browse files

show that we can ppack subcollections

  • Loading branch information...
1 parent acd90e0 commit bbbf8398badc16271edb6e8416be762489bfbab4 @rjbs committed Apr 6, 2012
Showing with 21 additions and 1 deletion.
  1. +2 −0 t/collections/filter.t
  2. +9 −0 t/lib/Book.pm
  3. +10 −1 t/lib/Library.pm
View
@@ -5,6 +5,8 @@ use Test::More;
use Test::Routine;
use Test::Routine::Util '-all';
+use Stick::Util qw(ppack);
+
use t::lib::Library;
use t::lib::Book;
View
@@ -28,4 +28,13 @@ sub as_str {
$self->id, $self->title, $self->author, $self->length;
}
+sub STICK_PACK {
+ my ($self) = @_;
+ return {
+ author => $self->author,
+ title => $self->title,
+ length => $self->length,
+ };
+}
+
1;
View
@@ -2,7 +2,9 @@ package t::lib::Library;
# ABSTRACT: Class for testing HasCollection
use Moose;
use Moose::Util::TypeConstraints qw(role_type);
-use MooseX::Types::Moose qw(HashRef);
+use MooseX::Types::Moose qw(HashRef Str);
+
+use Data::GUID ();
has by_id => (
is => 'ro',
@@ -14,6 +16,13 @@ has by_id => (
},
);
+has guid => (
+ is => 'ro',
+ isa => Str,
+ init_arg => undef,
+ default => sub { Data::GUID->new->as_string },
+);
+
with (
'Stick::Role::HasCollection' => {
item => 'book',

0 comments on commit bbbf839

Please sign in to comment.