File Coverage

blib/lib/Tree/Persist.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 37 39 94.8


line stmt bran cond sub pod time code
1             package Tree::Persist;
2              
3 5     5   101799 use strict;
  5         9  
  5         130  
4 5     5   17 use warnings;
  5         5  
  5         122  
5              
6 5     5   2192 use Module::Runtime;
  5         6300  
  5         29  
7              
8             our $VERSION = '1.13';
9              
10             # ----------------------------------------------
11              
12             sub connect
13             {
14 6     6 1 16780 my($class) = shift;
15 6         19 my($obj) = $class -> _instantiate( @_ );
16              
17 6         14 $obj -> _reload;
18              
19 6         18 return $obj;
20              
21             } # End of connect.
22              
23             # ----------------------------------------------
24              
25             sub create_datastore
26             {
27 4     4 1 159615402 my($class) = shift;
28 4         15 my($obj) = $class -> _instantiate( @_ );
29              
30 4         9 $obj -> _create;
31              
32 4         14 return $obj;
33              
34             } # End of create_datastore.
35              
36             # ----------------------------------------------
37              
38             sub _instantiate
39             {
40 10     10   12 my($self) = shift;
41 10         14 my($opts) = @_;
42 10         14 my($class) = delete $$opts{class};
43 10         18 my($type) = delete $$opts{type};
44              
45 10 100       29 if (! $class)
46             {
47 9 50       19 $type = 'File' if (! $type);
48 9 50       26 $class = $type eq 'File' ? 'Tree::Persist::File::XML' : 'Tree::Persist::DB::SelfReferential';
49             }
50              
51 10         30 return Module::Runtime::use_module($class)->new( $opts );
52              
53             } # End of _instantiate.
54              
55             # ----------------------------------------------
56              
57             1;
58              
59             __END__