File Coverage

blib/lib/Catalyst/Plugin/DataHash.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::DataHash;
2              
3 1     1   2637 use Moo::Role;
  1         11465  
  1         5  
4 1     1   2623 use CatalystX::InjectComponent;
  1         2651  
  1         69  
5              
6             our $VERSION = 1;
7              
8             before 'setup_components' => sub {
9             my $class = shift;
10             $class->config(default_model=>'DataHash');
11             CatalystX::InjectComponent->inject(
12             into => $class,
13             component => 'Catalyst::Model::DataHash',
14             as => 'Model::DataHash' );
15             };
16              
17             1;
18              
19             =head1 NAME
20              
21             Catalyst::Plugin::DataHash - Inject a Catalyst::Model::DataHash and make that default_model
22              
23             =head1 SYNOPSIS
24              
25             package MyApp;
26            
27             use Catalyst qw/DataHash/;
28              
29             MyApp->setup;
30              
31             =head1 DESCRIPTION
32              
33             Plugin that injects a model into your application that is based off
34             L<Catalyst::Model::DataHash> and sets that to be the default_model for the
35             application. This way you can use it without having to name the model in
36             your actions. For example:
37              
38             sub myaction :Local {
39             my ($self, $c) = @_;
40             $c->model->set(a=>1);
41             }
42              
43             =head1 SEE ALSO
44              
45             L<Catalyst>, L<Data::Perl::Role::Collection::Hash>, L<CatalystX::InjectComponent>.
46              
47             =head1 AUTHOR
48            
49             John Napiorkowski L<email:jjnapiork@cpan.org>
50            
51             =head1 COPYRIGHT & LICENSE
52            
53             Copyright 2015, John Napiorkowski L<email:jjnapiork@cpan.org>
54            
55             This library is free software; you can redistribute it and/or modify it under
56             the same terms as Perl itself.
57              
58             =cut