| Jifty documentation | Contained in the Jifty distribution. |
Jifty::Model::Metadata - Tracks Jifty-related metadata
my $app = Jifty->new(config_file => "$ProjectRoot/etc/config.yml");
my $application_version = Jifty::Model::Metadata->load("application_db_version");
Every Jifty application automatically inherits this table, which describes information about the Jifty database. It uses this information to smartly upgrade between application schema versions, as well as versions of Jifty itself, for instance.
Each schema is stored in the table _jifty_metadata.
The metadata table first appeared in Jifty version 0.60427
Fetches the given KEY from the metadata store. Returns undef if
such a key cannot be found.
Stores the given KEY in the database, overwriting the previous
value if it existed.
| Jifty documentation | Contained in the Jifty distribution. |
use warnings; use strict;
package Jifty::Model::Metadata; use Jifty::DBI::Schema; use Jifty::Record schema { column data_key => type is 'text'; column value => type is 'text'; }; use version; use base qw( Jifty::Record );
sub table {'_jifty_metadata'}
sub since {'0.60427'}
sub load { my $self = shift; $self = $self->new( current_user => Jifty->app_class('CurrentUser')->superuser ) unless ref $self; return undef unless $self->_handle and $self->_handle->dbh->ping; my ($key) = @_; # This may barf all over the place. That's almost expected in # some circumstances, so we eat all warnings and errors right # here, right now. eval { local $SIG{__WARN__} = sub { }; $self->load_by_cols( data_key => $key ); }; return undef unless $self->id; return $self->value; }
sub store { my $self = shift; $self = $self->new( current_user => Jifty->app_class('CurrentUser')->superuser ) unless ref $self; my ( $key, $value ) = @_; $self->load_by_cols( data_key => $key ); if ( $self->id ) { $self->set_value($value); } else { $self->create( data_key => $key, value => $value ); } } 1;