Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Created May 6, 2009 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothingmuch/107569 to your computer and use it in GitHub Desktop.
Save nothingmuch/107569 to your computer and use it in GitHub Desktop.
package Kitten::Friend::Schema::Kitten;
use Moose;
use Kitten::Friend::Schema::Vase;
use KiokuDB::Set;
use KiokuDB::Util qw(set);
use namespace::autoclean;
with qw(KiokuX::User); # provides 'id' and 'password' attributes
has name => (
isa => "Str",
is => "ro",
required => 1,
);
has friends => (
isa => "KiokuDB::Set",
is => "ro",
lazy => 1,
default => sub { set() }, # empty set
);
has vases => (
isa => "KiokuDB::Set",
is => "ro",
lazy => 1,
default => sub { set() },
);
sub new_vase {
my ( $self, @args ) = @_;
my $vase = Kitten::Friend::Schema::Vase->new(
owner => $self,
@args,
);
$self->vases->insert($vase);
return $vase;
}
sub add_friend {
my ( $self, $friend ) = @_;
$self->friends->insert($friend);
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment