File Coverage

blib/lib/Reply/Plugin/ORM/Otogiri.pm
Criterion Covered Total %
statement 15 35 42.8
branch 0 6 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 20 48 41.6


line stmt bran cond sub pod time code
1             package Reply::Plugin::ORM::Otogiri;
2 1     1   1282 use strict;
  1         2  
  1         34  
3 1     1   6 use warnings;
  1         2  
  1         31  
4              
5 1     1   1318 use List::Compare;
  1         27718  
  1         67  
6 1     1   13 use Module::Load;
  1         2  
  1         10  
7 1     1   60 use Path::Tiny;
  1         2  
  1         438  
8              
9             my @UNNECESSARY_METHODS = qw/
10             _deflate_param
11             _inflate_rows
12             BEGIN
13             import
14             load_plugin
15             maker
16             new
17             /;
18              
19             sub new {
20 0     0 0   my ($class, $db_name, $config, %opts) = @_;
21              
22 0           eval { require Otogiri };
  0            
23 0 0         Carp::croak "[Error] Module 'Otogiri' not found." if $@;
24 0           eval { require Otogiri::Plugin };
  0            
25 0 0         Carp::croak "[Error] Module 'Otogiri::Plugin' not found." if $@;
26              
27 0           load 'Otogiri';
28 0           load 'Otogiri::Plugin';
29              
30 0 0         if ($opts{otogiri_plugins}) {
31 0           Otogiri->load_plugin($_) for split /,/, $opts{otogiri_plugins};
32             }
33 0           my $orm = Otogiri->new( %{ $config } );
  0            
34              
35 0           my $list = List::Compare->new([ grep { $_ !~ /^_/ } keys %{DBIx::Otogiri::} ], \@UNNECESSARY_METHODS);
  0            
36 0           my @methods = map { s/(^.)/uc $1/e; $_ } $list->get_Lonly;
  0            
  0            
  0            
37              
38 0           return bless {
39             orm => $orm,
40             methods => \@methods,
41             }, $class;
42             }
43              
44             1;