DBIx-Model
view release on metacpan or search on metacpan
lib/DBIx/Model/Column.pm view on Meta::CPAN
our $VERSION = '0.0.1';
our $INLINE = {
chain => {
is => 'rw',
isa => Int,
},
table => {
is => 'ro',
required => 1,
weaken => 1,
},
name => {
is => 'ro',
isa => Str,
required => 1,
},
name_lc => {
is => 'ro',
init_arg => undef,
default => sub { lc $_[0]->name },
lib/DBIx/Model/Column.pm view on Meta::CPAN
"missing attribute DBIx::Model::Column::$_ is required")unless exists$self->
{$_}}'name','nullable','table','type';map {delete$self->{$_}}'full_name',
'full_name_lc','name_lc';if (@ATTRS_UNEX){map {local$Carp::CarpLevel=
$Carp::CarpLevel + 1;Carp::carp(
"DBIx::Model::Column attribute '$_' unexpected");delete$self->{$_ }}sort
grep {not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete
$self->{$_ };$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref
$class || $class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{
$_ })};Carp::croak(qq{DBIx::Model::Column::$_ value invalid ($@)})if $@}grep
{exists$self->{$_ }}'chain','name','nullable','primary','ref_count','size',
'target_count','type';map {Scalar::Util::weaken($self->{$_ })}grep {exists(
$self->{$_})&& defined$self->{$_ }}'table';my@check=('DBIx::Model::Column');
my@parents;while (@check){no strict 'refs';my$c=shift@check;push@parents,@{
$c .'::ISA'};push@check,@{$c .'::ISA'}}map {$_->BUILD()if exists &{$_.
'::BUILD'}}reverse@parents;$self->BUILD()if exists &{'BUILD'};$self}sub __ro
{my (undef,undef,undef,$sub)=caller(1);local$Carp::CarpLevel=
$Carp::CarpLevel + 1;Carp::croak("attribute $sub is read-only (value: '" .(
$_[1]// 'undef')."')")}sub chain {if (@_ > 1){$_[0]{'chain'}=eval {$INLINE->
{'chain'}->{'isa'}->($_[1])};Carp::croak(
'invalid (DBIx::Model::Column::chain) value: '.$@)if $@;return $_[0]}$_[0]{
'chain'}// undef}sub full_name {$_[0]->__ro($_[1])if @_ > 1;$_[0]{
lib/DBIx/Model/FK.pm view on Meta::CPAN
package DBIx::Model::FK;
use strict;
use warnings;
use Scalar::Util qw/weaken/;
use Types::Standard qw/ArrayRef/;
our $VERSION = '0.0.1';
our $INLINE = {
_columns => {
is => 'ro',
isa => ArrayRef,
init_arg => 'columns',
required => 1,
},
table => {
is => 'ro',
required => 1,
weaken => 1,
},
_to_columns => {
is => 'ro',
isa => ArrayRef,
init_arg => 'to_columns',
required => 1,
},
to_table => {
is => 'ro',
required => 1,
weaken => 1,
},
};
sub BUILD {
my $self = shift;
my @list = @{ $self->_columns };
foreach my $i ( 0 .. $#list ) {
weaken( $self->_columns->[$i] );
$self->_columns->[$i]->bump_ref_count;
}
@list = @{ $self->_to_columns };
foreach my $i ( 0 .. $#list ) {
weaken( $self->_to_columns->[$i] );
$self->_to_columns->[$i]->bump_target_count;
}
}
sub as_string {
my $self = shift;
my $prefix = shift;
my $str =
$prefix
. "FOREIGN KEY("
lib/DBIx/Model/FK.pm view on Meta::CPAN
"missing attribute DBIx::Model::FK::$_ is required")unless exists$self->{$_}
}'columns','to_columns','table','to_table';$self->{'_columns'}=delete$self->
{'columns'}if exists$self->{'columns'};$self->{'_to_columns'}=delete$self->{
'to_columns'}if exists$self->{'to_columns'};if (@ATTRS_UNEX){map {local
$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::carp(
"DBIx::Model::FK attribute '$_' unexpected");delete$self->{$_ }}sort grep {
not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete$self->{$_
};$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref$class ||
$class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{$_ })};
Carp::croak(qq{DBIx::Model::FK::$_ value invalid ($@)})if $@}grep {exists
$self->{$_ }}'_columns','_to_columns';map {Scalar::Util::weaken($self->{$_ }
)}grep {exists($self->{$_})&& defined$self->{$_ }}'table','to_table';my
@check=('DBIx::Model::FK');my@parents;while (@check){no strict 'refs';my$c=
shift@check;push@parents,@{$c .'::ISA'};push@check,@{$c .'::ISA'}}map {$_->
BUILD()if exists &{$_.'::BUILD'}}reverse@parents;$self->BUILD()if exists &{
'BUILD'};$self}sub __ro {my (undef,undef,undef,$sub)=caller(1);local
$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::croak(
"attribute $sub is read-only (value: '" .($_[1]// 'undef')."')")}sub
_columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_columns'}}sub _to_columns {$_[
0]->__ro($_[1])if @_ > 1;$_[0]{'_to_columns'}}sub table {$_[0]->__ro($_[1])
if @_ > 1;$_[0]{'table'}}sub to_table {$_[0]->__ro($_[1])if @_ > 1;$_[0]{
lib/DBIx/Model/Table.pm view on Meta::CPAN
our $VERSION = '0.0.1';
our $INLINE = {
_columns => {
is => 'ro',
isa => ArrayRef,
default => sub { [] },
},
db => {
is => 'ro',
required => 1,
weaken => 1,
},
name => {
is => 'ro',
required => 1,
},
name_lc => {
is => 'ro',
init_arg => undef,
default => sub { lc $_[0]->name },
},
lib/DBIx/Model/Table.pm view on Meta::CPAN
$Carp::CarpLevel + 1;Carp::croak(
"missing attribute DBIx::Model::Table::$_ is required")unless exists$self->{
$_}}'db','name','type';map {delete$self->{$_}}'name_lc';if (@ATTRS_UNEX){map
{local$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::carp(
"DBIx::Model::Table attribute '$_' unexpected");delete$self->{$_ }}sort grep
{not exists$INLINE->{$_ }}keys %$self}else {@ATTRS_UNEX=map {delete$self->{
$_ };$_}grep {not exists$INLINE->{$_ }}keys %$self}bless$self,ref$class ||
$class;map {$self->{$_ }=eval {$INLINE->{$_ }->{'isa'}->($self->{$_ })};
Carp::croak(qq{DBIx::Model::Table::$_ value invalid ($@)})if $@}grep {exists
$self->{$_ }}'_columns','_foreign_keys','ref_count','target_count';map {
Scalar::Util::weaken($self->{$_ })}grep {exists($self->{$_})&& defined$self
->{$_ }}'db';my@check=('DBIx::Model::Table');my@parents;while (@check){no
strict 'refs';my$c=shift@check;push@parents,@{$c .'::ISA'};push@check,@{$c .
'::ISA'}}map {$_->BUILD()if exists &{$_.'::BUILD'}}reverse@parents;$self->
BUILD()if exists &{'BUILD'};$self}sub __ro {my (undef,undef,undef,$sub)=
caller(1);local$Carp::CarpLevel=$Carp::CarpLevel + 1;Carp::croak(
"attribute $sub is read-only (value: '" .($_[1]// 'undef')."')")}sub
_columns {$_[0]->__ro($_[1])if @_ > 1;$_[0]{'_columns'}//= eval {$INLINE->{
'_columns'}->{'isa'}->($INLINE->{'_columns'}->{'default'}->($_[0]))};
Carp::croak('invalid (DBIx::Model::Table::_columns) default value: ' .$@)if
$@;$_[0]{'_columns'}}sub _foreign_keys {$_[0]->__ro($_[1])if @_ > 1;$_[0]{
( run in 0.240 second using v1.01-cache-2.11-cpan-65fba6d93b7 )