| 1 | package Class::MVC; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = '0.01.06'; | |||||||||
| 8 | |||||||||||
| 9 | 1 | our $DEBUG = 0; | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Class::Maker qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use Class::Listener; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Class::Observable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | # The Facade | ||||||||||
| 18 | |||||||||||
| 19 | 1 | Class::Maker::class | |||||||||
| 20 | { | ||||||||||
| 21 | public => | ||||||||||
| 22 | { | ||||||||||
| 23 | ref => [qw( model view controller )], | ||||||||||
| 24 | }, | ||||||||||
| 25 | }; | ||||||||||
| 26 | |||||||||||
| 27 | 0 | ▶ | sub _preinit : method | ||||||||
|
Subroutine
_preinit: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | { | ||||||||||
| 29 | 0 | my $this = shift; | |||||||||
| 30 | |||||||||||
| 31 | 0 | $this->controller( ( ref($this).'::Controller' )->new() ); | |||||||||
| 32 | |||||||||||
| 33 | 0 | $this->model( ( ref($this).'::Model' )->new() ); | |||||||||
| 34 | |||||||||||
| 35 | 0 | $this->view( ( ref($this).'::View' )->new() ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub _postinit : method | ||||||||
|
Subroutine
_postinit: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | { | ||||||||||
| 40 | 0 | my $this = shift; | |||||||||
| 41 | |||||||||||
| 42 | 0 | $this->interconnect(); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub interconnect : method | ||||||||
|
Subroutine
interconnect: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||
| 46 | { | ||||||||||
| 47 | 0 | my $this = shift; | |||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | $this->view->model( $this->model ) if $this->model; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | $this->view->controller( $this->controller ) if $this->controller; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | $this->controller->model( $this->model ) if $this->model; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | $this->controller->view( $this->view ) if $this->view; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | $this->model->add_observer( $this->view ) if $this->view; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | package Class::MVC::Model; | ||||||||||
| 61 | |||||||||||
| 62 | 1 | Class::Maker::class | |||||||||
| 63 | { | ||||||||||
| 64 | isa => [qw( Class::Observable )], | ||||||||||
| 65 | |||||||||||
| 66 | }; | ||||||||||
| 67 | |||||||||||
| 68 | sub DESTROY | ||||||||||
| 69 | 0 | ▶ | { | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||
| 70 | 0 | my $this = shift; | |||||||||
| 71 | |||||||||||
| 72 | 0 | $this->delete_observers; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | package Class::MVC::View; | ||||||||||
| 76 | |||||||||||
| 77 | 1 | Class::Maker::class | |||||||||
| 78 | { | ||||||||||
| 79 | isa => [qw( Class::Listener )], | ||||||||||
| 80 | |||||||||||
| 81 | public => | ||||||||||
| 82 | { | ||||||||||
| 83 | ref => [qw( controller model )], | ||||||||||
| 84 | }, | ||||||||||
| 85 | }; | ||||||||||
| 86 | |||||||||||
| 87 | # dispatch method for Observer ( see Class::Observable ) | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | sub update : method | ||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
| |||||||||||
| 90 | { | ||||||||||
| 91 | 0 | my $this = shift; | |||||||||
| 92 | |||||||||||
| 93 | 0 | my ( $object, $action ) = @_; | |||||||||
| 94 | |||||||||||
| 95 | 0 | return $this->Class::Listener::signal( $action, $object ); | |||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | package Class::MVC::CompositeView; | ||||||||||
| 99 | |||||||||||
| 100 | 1 | Class::Maker::class | |||||||||
| 101 | { | ||||||||||
| 102 | isa => [qw( Class::MVC::View )], | ||||||||||
| 103 | |||||||||||
| 104 | public => | ||||||||||
| 105 | { | ||||||||||
| 106 | # The subView/superView relationship | ||||||||||
| 107 | |||||||||||
| 108 | ref => [qw( super_view )], | ||||||||||
| 109 | }, | ||||||||||
| 110 | }; | ||||||||||
| 111 | |||||||||||
| 112 | # not implemented | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub sub_views : method | ||||||||
|
Subroutine
sub_views: not called CC=1 SCAR=6.9
| |||||||||||
| 115 | { | ||||||||||
| 116 | 0 | my $this = shift; | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 0 | ▶ | sub update : method | ||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
| |||||||||||
| 120 | { | ||||||||||
| 121 | 0 | my $this = shift; | |||||||||
| 122 | |||||||||||
| 123 | # update yourself | ||||||||||
| 124 | |||||||||||
| 125 | 0 | $this->SUPER::update( @_ ); | |||||||||
| 126 | |||||||||||
| 127 | # and your superviews | ||||||||||
| 128 | |||||||||||
| 129 | 0 | ▶ | $this->super_view->update( @_ ) if $this->super_view; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | package Class::MVC::Controller; | ||||||||||
| 133 | |||||||||||
| 134 | 1 | Class::Maker::class | |||||||||
| 135 | { | ||||||||||
| 136 | public => | ||||||||||
| 137 | { | ||||||||||
| 138 | ref => [qw( model view )], | ||||||||||
| 139 | }, | ||||||||||
| 140 | }; | ||||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub _postinit : method | ||||||||
|
Subroutine
_postinit: not called CC=1 SCAR=6.9
| |||||||||||
| 143 | { | ||||||||||
| 144 | 0 | my $this = shift; | |||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 0 | ▶ | sub update_model : method | ||||||||
|
Subroutine
update_model: not called CC=1 SCAR=6.9
| |||||||||||
| 148 | { | ||||||||||
| 149 | 0 | my $this = shift; | |||||||||
| 150 | |||||||||||
| 151 | # call Model methods from here | ||||||||||
| 152 | |||||||||||
| 153 | 0 | $this->model->Class::Listener::signal( 'update', $this, @_ ); | |||||||||
| 154 | } | ||||||||||
| 155 | |||||||||||
| 156 | 0 | ▶ | sub change_view : method | ||||||||
|
Subroutine
change_view: not called CC=1 SCAR=6.9
| |||||||||||
| 157 | { | ||||||||||
| 158 | 0 | my $this = shift; | |||||||||
| 159 | |||||||||||
| 160 | # call View methods from here | ||||||||||
| 161 | |||||||||||
| 162 | 0 | $this->view->Class::Listener::signal( 'change', $this, @_ ); | |||||||||
| 163 | } | ||||||||||
| 164 | |||||||||||
| 165 | 1 | 1; | |||||||||
| 166 | |||||||||||
| 167 | __END__ | ||||||||||