summaryrefslogtreecommitdiffstats
path: root/lib/Narwhal/Page.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Narwhal/Page.pm')
-rw-r--r--lib/Narwhal/Page.pm38
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/Narwhal/Page.pm b/lib/Narwhal/Page.pm
index d3e0a4d..70f2f87 100644
--- a/lib/Narwhal/Page.pm
+++ b/lib/Narwhal/Page.pm
@@ -1,11 +1,43 @@
package Narwhal::Page;
use Moose;
-has text => (
- is => 'ro',
- isa => 'Str',
+use Narwhal::Page::Revision;
+
+with 'KiokuDB::Role::ID';
+
+has id => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+);
+
+has current_revision => (
+ is => 'rw',
+ isa => 'Narwhal::Page::Revision',
+ required => 1,
+ handles => ['text', 'author', 'modification_date'],
);
+sub kiokudb_object_id { 'page:' . shift->id }
+
+sub new_revision {
+ my $self = shift;
+ my $rev = $self->current_revision->new_revision(@_);
+ $self->current_revision($rev);
+ return $rev;
+}
+
+sub new_page {
+ my $class = shift;
+ my %opts = @_;
+ my $id = delete $opts{id};
+ my $rev = Narwhal::Page::Revision->new(%opts);
+ return $class->new(
+ id => $id,
+ current_revision => $rev,
+ );
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;