| File: | blib/lib/MySQL/Util/Lite.pm |
| Coverage: | 87.5% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | package MySQL::Util::Lite; | ||||
| 2 | |||||
| 3 | our $VERSION = '0.01'; | ||||
| 4 | |||||
| 5 | 1 1 1 | use Modern::Perl; | |||
| 6 | 1 1 1 | use Moose; | |||
| 7 | 1 1 1 | use namespace::autoclean; | |||
| 8 | 1 1 1 | use Method::Signatures; | |||
| 9 | 1 1 1 | use Data::Printer alias => 'pdump'; | |||
| 10 | 1 1 1 | use MySQL::Util::Lite::Schema; | |||
| 11 | |||||
| 12 | extends 'MySQL::Util'; | ||||
| 13 | |||||
| 14 | ############################### | ||||
| 15 | ###### PUBLIC ATTRIBUTES ###### | ||||
| 16 | ############################### | ||||
| 17 | |||||
| 18 | has 'dsn' => ( | ||||
| 19 | is => 'ro', | ||||
| 20 | isa => 'Str', | ||||
| 21 | required => 0 | ||||
| 22 | ); | ||||
| 23 | |||||
| 24 | has 'user' => ( | ||||
| 25 | is => 'ro', | ||||
| 26 | isa => 'Str', | ||||
| 27 | required => 0 | ||||
| 28 | ); | ||||
| 29 | |||||
| 30 | has 'pass' => ( | ||||
| 31 | is => 'ro', | ||||
| 32 | required => 0, | ||||
| 33 | default => undef | ||||
| 34 | ); | ||||
| 35 | |||||
| 36 | has 'span' => ( | ||||
| 37 | is => 'ro', | ||||
| 38 | isa => 'Int', | ||||
| 39 | required => 0, | ||||
| 40 | default => 0 | ||||
| 41 | ); | ||||
| 42 | |||||
| 43 | has 'dbh' => ( | ||||
| 44 | is => 'rw', | ||||
| 45 | isa => 'Object', | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | ################################ | ||||
| 49 | ###### PRIVATE_ATTRIBUTES ###### | ||||
| 50 | ################################ | ||||
| 51 | |||||
| 52 | has _util => ( | ||||
| 53 | is => 'ro', | ||||
| 54 | isa => 'MySQL::Util', | ||||
| 55 | lazy => 1, | ||||
| 56 | builder => '_build_util', | ||||
| 57 | ); | ||||
| 58 | |||||
| 59 | ############################ | ||||
| 60 | ###### PUBLIC METHODS ###### | ||||
| 61 | ############################ | ||||
| 62 | |||||
| 63 | 1 1 1 | method get_schema { | |||
| 64 | |||||
| 65 | 1 | return my $schema = MySQL::Util::Lite::Schema->new( | |||
| 66 | name => $self->_util->get_dbname, | ||||
| 67 | _util => $self->_util | ||||
| 68 | ); | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | ############################# | ||||
| 72 | ###### PRIVATE METHODS ###### | ||||
| 73 | ############################# | ||||
| 74 | |||||
| 75 | 1 1 1 | method _build_util { | |||
| 76 | |||||
| 77 | 1 | my %new; | |||
| 78 | 1 | $new{dsn} = $self->dsn if defined $self->dsn; | |||
| 79 | 1 | $new{user} = $self->user if defined $self->user; | |||
| 80 | 1 | $new{pass} = $self->pass if defined $self->pass; | |||
| 81 | 1 | $new{span} = $self->span if defined $self->span; | |||
| 82 | 1 | $new{dbh} = $self->dbh if defined $self->dbh; | |||
| 83 | |||||
| 84 | 1 | return MySQL::Util->new(%new); | |||
| 85 | } | ||||
| 86 | |||||
| 87 | 1; | ||||