Alzabo

 view release on metacpan or  search on metacpan

lib/Alzabo/Column.pm  view on Meta::CPAN

package Alzabo::Column;

use strict;
use vars qw($VERSION);

use Alzabo;

use Tie::IxHash;

use Params::Validate qw( :all );
Params::Validate::validation_options( on_fail => sub { Alzabo::Exception::Params->throw( error => join '', @_ ) } );

$VERSION = 2.0;

1;

sub table
{
    $_[0]->{table};
}

sub name
{
    $_[0]->{name};
}

sub nullable
{
    $_[0]->{nullable};
}

sub attributes
{
    return keys %{ $_[0]->{attributes} };
}

sub has_attribute
{
    my $self = shift;
    my %p = validate( @_, { attribute => { type => SCALAR },
                            case_sensitive => { type => SCALAR,
                                                default => 0 } } );

    if ( $p{case_sensitive} )
    {
        return exists $self->{attributes}{ $p{attribute} };
    }
    else
    {
        return 1 if grep { lc $p{attribute} eq lc $_ } keys %{ $self->{attributes} };
    }
}

sub type
{
    $_[0]->definition->type;
}

sub sequenced
{
    $_[0]->{sequenced};
}

sub default
{
    $_[0]->{default};
}

sub default_is_raw
{
    $_[0]->{default_is_raw};
}

sub length
{
    $_[0]->definition->length;
}

sub precision
{
    $_[0]->definition->precision;
}

sub definition
{
    $_[0]->{definition};
}

sub is_primary_key
{
    $_[0]->table->column_is_primary_key($_[0]);
}

sub is_numeric
{
    $_[0]->table->schema->rules->type_is_numeric($_[0]);
}

sub is_integer
{



( run in 3.490 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )