| 1 | ########################################################### | ||
| 2 | # SIOC::Container | ||
| 3 | # Container class for the SIOC ontology | ||
| 4 | ########################################################### | ||
| 5 | # | ||
| 6 | # $Id: Container.pm 10 2008-03-01 21:38:39Z geewiz $ | ||
| 7 | # | ||
| 8 | |||
| 9 | package SIOC::Container; | ||
| 10 | |||
| 11 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 5 | ▶ | use version; our $VERSION = qv(1.0.0); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | 5 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | 5 | extends 'SIOC'; | |
| 19 | |||
| 20 | ### optional attributes | ||
| 21 | |||
| 22 | # parent container/forum | ||
| 23 | 5 | has 'parent' => ( | |
| 24 | isa => 'SIOC::Container', | ||
| 25 | is => 'rw', | ||
| 26 | ); | ||
| 27 | |||
| 28 | # child containers/forums | ||
| 29 | has 'children' => ( | ||
| 30 | isa => 'ArrayRef[SIOC::Container]', | ||
| 31 | metaclass => 'Collection::Array', | ||
| 32 | is => 'rw', | ||
| 33 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 34 | 5 | provides => { | |
| 35 | 'push' => 'add_child', | ||
| 36 | }, | ||
| 37 | ); | ||
| 38 | |||
| 39 | # contained items/posts | ||
| 40 | has 'items' => ( | ||
| 41 | isa => 'ArrayRef[SIOC::Item]', | ||
| 42 | metaclass => 'Collection::Array', | ||
| 43 | is => 'rw', | ||
| 44 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 45 | 5 | provides => { | |
| 46 | 'push' => 'add_item', | ||
| 47 | }, | ||
| 48 | ); | ||
| 49 | |||
| 50 | # user that owns this container | ||
| 51 | 5 | has 'owner' => ( | |
| 52 | isa => 'SIOC::User', | ||
| 53 | is => 'rw', | ||
| 54 | ); | ||
| 55 | |||
| 56 | # users that subscribe to this container | ||
| 57 | has 'subscribers' => ( | ||
| 58 | isa => 'ArrayRef[SIOC::User]', | ||
| 59 | metaclass => 'Collection::Array', | ||
| 60 | is => 'rw', | ||
| 61 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 62 | 5 | provides => { | |
| 63 | 'push' => 'add_subscriber', | ||
| 64 | }, | ||
| 65 | ); | ||
| 66 | |||
| 67 | ### methods | ||
| 68 | |||
| 69 | 0 | ▶ | after 'fill_template' => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 70 | 0 | my ($self) = @_; | |
| 71 | |||
| 72 | 0 | $self->set_template_var(parent => $self->parent); | |
| 73 | 0 | $self->set_template_var(children => $self->children); | |
| 74 | 0 | $self->set_template_var(items => $self->items); | |
| 75 | 0 | $self->set_template_var(owner => $self->owner); | |
| 76 | 0 | $self->set_template_var(subscribers => $self->subscribers); | |
| 77 | 5 | }; | |
| 78 | |||
| 79 | 5 | 1; | |
| 80 | __END__ | ||