Jifty/Model/Metadata.pm

filter: Statementstmt 53.8% 21 / 39 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 100% 3 / 3 totaltotal 44.9% 31 / 69 CC 7 SCAR 24.0
CC
7
Cov
40%
load
30.0
store
12.0
table
2.0
CRAP 11.1
« Jifty/Web/Form/Field/Button.pm ↑ Summary Jifty/CAS/Store.pm »
1 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 =head1 NAME
5  
6 Jifty::Model::Metadata - Tracks Jifty-related metadata
7  
8 =head1 SYNOPSIS
9  
10 my $app = Jifty->new(config_file => "$ProjectRoot/etc/config.yml");
11 my $application_version = Jifty::Model::Metadata->load("application_db_version");
12  
13 =head1 DESCRIPTION
14  
15 Every Jifty application automatically inherits this table, which
16 describes information about the Jifty database. It uses this
17 information to smartly upgrade between application schema versions, as well
18 as versions of Jifty itself, for instance.
19  
20 =cut
21  
22 package Jifty::Model::Metadata;
23  
24 1 ▶use Jifty::DBI::Schema;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Jifty::Record schema {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
26  
27 1 column data_key => type is 'text';
28 1 column value => type is 'text';
29 1 };
30  
31 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶use base qw( Jifty::Record );
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 =head2 table
36  
37 Each schema is stored in the table C<_jifty_metadata>.
38  
39 =cut
40  
41 0 ▶sub table {'_jifty_metadata'}
Subroutine table: not called CC=1 SCAR=6.9
Pod documented
42  
43 =head2 since
44  
45 The metadata table first appeared in Jifty version 0.60427
46  
47 =cut
48  
49 0 ▶sub since {'0.60427'}
Subroutine since: not called CC=1 SCAR=6.9
50  
51 =head2 load KEY
52  
53 Fetches the given C<KEY> from the metadata store. Returns undef if
54 such a key cannot be found.
55  
56 =cut
57  
58 0 ▶sub load {
Subroutine load: not called CC=5 SCAR=34.0
Pod documented
59 0 my $self = shift;
60 0 ▶ $self = $self->new( current_user => Jifty->app_class('CurrentUser')->superuser )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
61 unless ref $self;
62 0 ▶ return undef unless $self->_handle and $self->_handle->dbh->ping;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_handle and $self->_handle->dbh->ping 0 0 0
Condition0%0/3
$self->_handle and $self->_handle->dbh->ping
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_handle and $self->_handle->dbh->ping
$self->_handle $self->_handle->dbh->ping
Truth table0%0/3
A and B
A= $self->_handleB= $self->_handle->dbh->ping
ABresult
0X0
100
111
63  
64 0 my ($key) = @_;
65  
66 # This may barf all over the place. That's almost expected in
67 # some circumstances, so we eat all warnings and errors right
68 # here, right now.
69 0 eval {
70 0 ▶ local $SIG{__WARN__} = sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 0 $self->load_by_cols( data_key => $key );
72 };
73 0 ▶ return undef unless $self->id;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->id 0 0 0
74 0 return $self->value;
75 }
76  
77 =head2 store KEY => VALUE
78  
79 Stores the given C<KEY> in the database, overwriting the previous
80 value if it existed.
81  
82 =cut
83  
84 0 ▶sub store {
Subroutine store: not called CC=3 SCAR=24.8
Pod documented
85 0 my $self = shift;
86 0 ▶ $self = $self->new( current_user => Jifty->app_class('CurrentUser')->superuser )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
87 unless ref $self;
88  
89 0 my ( $key, $value ) = @_;
90 0 $self->load_by_cols( data_key => $key );
91 0 ▶ if ( $self->id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->id) { } 0 0 0
92 0 $self->set_value($value);
93 } else {
94 0 $self->create( data_key => $key, value => $value );
95 }
96 }
97  
98 1 1;
« Jifty/Web/Form/Field/Button.pm ↑ Summary Jifty/CAS/Store.pm »