summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-02-18 00:43:09 -0600
committerJesse Luehrs <doy@tozt.net>2011-02-18 00:43:09 -0600
commit0d5a97a87d1e42626f8e21b36ef327afd556865c (patch)
tree50d8e62e8446ab3112e9c5d740fb461d673b573f
parentb815a6f9be0eb015728b3fb7e8b0ec6cfba94dfe (diff)
downloadnarwhal-0d5a97a87d1e42626f8e21b36ef327afd556865c.tar.gz
narwhal-0d5a97a87d1e42626f8e21b36ef327afd556865c.zip
don't duplicate user objects
-rw-r--r--lib/Narwhal/Component/Wiki/Edit.pm7
-rw-r--r--lib/Narwhal/User.pm10
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/Narwhal/Component/Wiki/Edit.pm b/lib/Narwhal/Component/Wiki/Edit.pm
index 1623d9a..3631e84 100644
--- a/lib/Narwhal/Component/Wiki/Edit.pm
+++ b/lib/Narwhal/Component/Wiki/Edit.pm
@@ -35,17 +35,20 @@ sub post {
$self->txn_do(sub {
my $page = $self->lookup("page:$page_name");
+ my $user_id = 'foo'; # XXX
+ my $user = $self->lookup("user:$user_id")
+ || Narwhal::User->new(id => $user_id);
if ($page) {
$page->new_revision(
text => $req->param('text'),
- author => Narwhal::User->new(id => 'foo'), # XXX
+ author => $user,
);
}
else {
$page = Narwhal::Page->new_page(
id => $page_name,
text => $req->param('text'),
- author => Narwhal::User->new(id => 'foo'), # XXX
+ author => $user,
);
}
$self->store($page);
diff --git a/lib/Narwhal/User.pm b/lib/Narwhal/User.pm
index 6bb66c6..5ce4a63 100644
--- a/lib/Narwhal/User.pm
+++ b/lib/Narwhal/User.pm
@@ -1,12 +1,22 @@
package Narwhal::User;
use Moose;
+with 'KiokuDB::Role::ID';
+
has id => (
is => 'ro',
isa => 'Str',
required => 1,
);
+has is_anon => (
+ is => 'ro',
+ isa => 'Str',
+ default => 0,
+);
+
+sub kiokudb_object_id { 'user:' . shift->id }
+
__PACKAGE__->meta->make_immutable;
no Moose;