line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Widget::Base; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Catalyst::Plugin::Widget::Base - Base class for all kind of widgets |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3077
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
60
|
|
10
|
1
|
|
|
1
|
|
784
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload |
13
|
|
|
|
|
|
|
'""' => 'render', |
14
|
|
|
|
|
|
|
bool => sub { ref shift }, |
15
|
|
|
|
|
|
|
; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 new ( $context, %attributes ) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Create widget instance with current Catalyst context. |
23
|
|
|
|
|
|
|
First and required argument for all Catalyst::Plugin::Widget::Base subclasses |
24
|
|
|
|
|
|
|
must be a Catalyst context (usually $c in your controller). |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
around BUILDARGS => sub { |
29
|
|
|
|
|
|
|
my ( $orig,$class,$context ) = splice @_,0,3; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
+{ context => $context, %{ $class->$orig( @_ ) } }; |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 context |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Returns current Catalyst application context. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has context => ( is => 'ro', isa => 'Catalyst', required => 1 ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 render |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Render widget to string (must be overriden in subclasses). |
49
|
|
|
|
|
|
|
This method called implicitly during widget stringification, |
50
|
|
|
|
|
|
|
so you can do something like: |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$c->res->body( "<html>$widget</html> ) |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub render { |
57
|
|
|
|
|
|
|
croak 'Not implemented: ' . ref(shift) .'::render'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|