| 1 | ########################################################### | ||
| 2 | # SIOC::Item | ||
| 3 | # Item class for the SIOC ontology | ||
| 4 | ########################################################### | ||
| 5 | # | ||
| 6 | # $Id: Item.pm 10 2008-03-01 21:38:39Z geewiz $ | ||
| 7 | # | ||
| 8 | |||
| 9 | package SIOC::Item; | ||
| 10 | |||
| 11 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 4 | ▶ | use version; our $VERSION = qv(1.0.0); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | 4 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 4 | ▶ | use MooseX::AttributeHelpers; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | |||
| 19 | 4 | extends 'SIOC'; | |
| 20 | |||
| 21 | ### required attributes | ||
| 22 | |||
| 23 | 4 | has 'created' => ( | |
| 24 | isa => 'Str', | ||
| 25 | is => 'rw', | ||
| 26 | required => 1, | ||
| 27 | ); | ||
| 28 | |||
| 29 | 4 | has 'creator' => ( | |
| 30 | isa => 'SIOC::User', | ||
| 31 | is => 'rw', | ||
| 32 | required => 1, | ||
| 33 | ); | ||
| 34 | |||
| 35 | ### optional attributes | ||
| 36 | |||
| 37 | 4 | has 'modified' => ( | |
| 38 | isa => 'Str', | ||
| 39 | is => 'rw' | ||
| 40 | ); | ||
| 41 | |||
| 42 | 4 | has 'modifier' => ( | |
| 43 | isa => 'SIOC::User', | ||
| 44 | is => 'rw', | ||
| 45 | ); | ||
| 46 | |||
| 47 | 4 | has 'view_count' => ( | |
| 48 | isa => 'Num', | ||
| 49 | is => 'rw', | ||
| 50 | ); | ||
| 51 | |||
| 52 | 4 | has 'about' => ( | |
| 53 | isa => 'Str', | ||
| 54 | is => 'rw', | ||
| 55 | ); | ||
| 56 | |||
| 57 | 4 | has 'container' => ( | |
| 58 | isa => 'SIOC::Container', | ||
| 59 | is => 'rw', | ||
| 60 | ); | ||
| 61 | |||
| 62 | has 'parent_posts' => ( | ||
| 63 | isa => 'ArrayRef[SIOC::Item]', | ||
| 64 | metaclass => 'Collection::Array', | ||
| 65 | is => 'rw', | ||
| 66 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 67 | 4 | provides => { | |
| 68 | 'push' => 'add_parent_post', | ||
| 69 | }, | ||
| 70 | ); | ||
| 71 | |||
| 72 | has 'reply_posts' => ( | ||
| 73 | isa => 'ArrayRef[SIOC::Item]', | ||
| 74 | metaclass => 'Collection::Array', | ||
| 75 | is => 'rw', | ||
| 76 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 77 | 4 | provides => { | |
| 78 | 'push' => 'add_reply_post', | ||
| 79 | }, | ||
| 80 | ); | ||
| 81 | |||
| 82 | 4 | has 'ip_address' => ( | |
| 83 | isa => 'Str', | ||
| 84 | is => 'rw', | ||
| 85 | ); | ||
| 86 | |||
| 87 | 4 | has 'previous_by_date' => ( | |
| 88 | isa => 'SIOC::Item', | ||
| 89 | is => 'rw', | ||
| 90 | ); | ||
| 91 | |||
| 92 | 4 | has 'next_by_date' => ( | |
| 93 | isa => 'SIOC::Item', | ||
| 94 | is => 'rw', | ||
| 95 | ); | ||
| 96 | |||
| 97 | 4 | has 'previous_version' => ( | |
| 98 | isa => 'SIOC::Item', | ||
| 99 | is => 'rw', | ||
| 100 | ); | ||
| 101 | |||
| 102 | 4 | has 'next_version' => ( | |
| 103 | isa => 'SIOC::Item', | ||
| 104 | is => 'rw', | ||
| 105 | ); | ||
| 106 | |||
| 107 | ### methods | ||
| 108 | |||
| 109 | 0 | ▶ | after 'fill_template' => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 110 | 0 | my ($self) = @_; | |
| 111 | |||
| 112 | 0 | $self->set_template_var(created => $self->created); | |
| 113 | 0 | $self->set_template_var(creator => $self->creator); | |
| 114 | 4 | }; | |
| 115 | |||
| 116 | 4 | 1; | |
| 117 | __END__ | ||