summaryrefslogtreecommitdiffstats
path: root/lib/Narwhal/Page
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-02-17 23:43:35 -0600
committerJesse Luehrs <doy@tozt.net>2011-02-17 23:43:35 -0600
commit2d2750b4c40f4ec2016b61ee244cb435b6e9a4e8 (patch)
treedf6b0f39039c7d586219f2c46cc78d6e1bf7123c /lib/Narwhal/Page
parent58a447a99980b9921d498444a72f1705823a049e (diff)
downloadnarwhal-2d2750b4c40f4ec2016b61ee244cb435b6e9a4e8.tar.gz
narwhal-2d2750b4c40f4ec2016b61ee244cb435b6e9a4e8.zip
flesh out the data model a bit
Diffstat (limited to 'lib/Narwhal/Page')
-rw-r--r--lib/Narwhal/Page/Revision.pm53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/Narwhal/Page/Revision.pm b/lib/Narwhal/Page/Revision.pm
new file mode 100644
index 0000000..08a21c9
--- /dev/null
+++ b/lib/Narwhal/Page/Revision.pm
@@ -0,0 +1,53 @@
+package Narwhal::Page::Revision;
+use KiokuDB::Class;
+
+use DateTime;
+
+with 'KiokuDB::Role::ID::Digest', 'MooseX::Clone';
+
+has text => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+);
+
+has author => (
+ is => 'ro',
+ isa => 'Narwhal::User',
+ required => 1,
+);
+
+has modification_date => (
+ traits => ['NoClone'],
+ is => 'ro',
+ isa => 'DateTime',
+ default => sub { DateTime->now },
+);
+
+has previous_revision => (
+ traits => ['KiokuDB::Lazy'],
+ is => 'ro',
+ isa => 'Narwhal::Page::Revision',
+);
+
+sub new_revision {
+ my $self = shift;
+ $self->clone(
+ previous_revision => $self,
+ @_,
+ );
+}
+
+sub digest_parts {
+ my $self = shift;
+ return (
+ $self->text,
+ $self->modification_date->iso8601,
+ $self->author->id,
+ );
+}
+
+__PACKAGE__->meta->make_immutable;
+no KiokuDB::Class;
+
+1;