line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Model::Factory; |
2
|
1
|
|
|
1
|
|
16259
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
3
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
6
|
use MRO::Compat; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
16
|
use base 'Catalyst::Model::Adaptor::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
7
|
1
|
|
|
1
|
|
503
|
use Catalyst::Utils (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Scalar::Util 'blessed'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub COMPONENT { |
13
|
|
|
|
|
|
|
my ($class, @args) = @_; |
14
|
|
|
|
|
|
|
my $self = $class->next::method(@args); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$self->_load_adapted_class; |
17
|
|
|
|
|
|
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub ACCEPT_CONTEXT { |
21
|
|
|
|
|
|
|
my ($self, $context, @args) = @_; |
22
|
|
|
|
|
|
|
my $arg = {}; |
23
|
|
|
|
|
|
|
if ( scalar @args ) { |
24
|
|
|
|
|
|
|
if ( ref($args[0]) eq 'HASH' ) { |
25
|
|
|
|
|
|
|
$arg = $args[0]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
|
|
|
|
|
|
$arg = { @args }; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
my $suffix = Catalyst::Utils::class2classsuffix(blessed $self); |
32
|
|
|
|
|
|
|
return $self->_create_instance( |
33
|
|
|
|
|
|
|
$context, |
34
|
|
|
|
|
|
|
$self->merge_config_hashes($context->config->{$suffix} || {}, $arg), |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catalyst::Model::Factory - use a plain class as a Catalyst model, |
44
|
|
|
|
|
|
|
instantiating it every time it is requested |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This module works just like |
49
|
|
|
|
|
|
|
L<Catalyst::Model::Adaptor|Catalyst::Model::Adaptor>, except that a |
50
|
|
|
|
|
|
|
fresh instance of your adapted class is created every time it is |
51
|
|
|
|
|
|
|
requested via C<< $c->model >>. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 CUSTOMIZING |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
You can customize your subclass just like |
56
|
|
|
|
|
|
|
L<Catalyst::Model::Adaptor|Catalyst::Model::Adaptor>. Instead of |
57
|
|
|
|
|
|
|
C<$app>, though, you'll get C<$c>, the current request context. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
These methods are called by Catalyst, not by you: |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 COMPONENT |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Load your class |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 ACCEPT_CONTEXT |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Create an instance of your class and return it. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
For all the critical documentation, see L<Catalyst::Model::Adaptor>. |