Alzabo::Runtime::Column - Column objects


Alzabo documentation Contained in the Alzabo distribution.

Index


Code Index:

NAME

Top

Alzabo::Runtime::Column - Column objects

SYNOPSIS

Top

  use Alzabo::Runtime::Column;

INHERITS FROM

Top

Alzabo::Column

alias

Takes the following parameters:

* as => $name

This method returns an object that can be used in calls to the table and schema select() methods in order to change the name given to the column if next_as_hash() is called on the Alzabo::DriverStatement|Alzabo::Driver/Alzabo::DriverStatment returned by the aforementioned select() method.

AUTHOR

Top

Dave Rolsky, <autarch@urth.org>


Alzabo documentation Contained in the Alzabo distribution.

package Alzabo::Runtime::Column;

use strict;
use vars qw($VERSION);

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

use base qw(Alzabo::Column);

$VERSION = 2.0;

sub alias_clone
{
    my $self = shift;

    my %p = validate( @_, { table => { isa => 'Alzabo::Runtime::Table' },
                          } );

    my $clone;

    %$clone = %$self;
    $clone->{table} = $p{table};

    bless $clone, ref $self;

    return $clone;
}

sub alias
{
    my $self = shift;
    my %p = validate( @_, { as => { type => SCALAR } } );

    my $clone;
    %$clone = %$self;

    bless $clone, ref $self;

    $clone->{alias_name} = $p{as};
    $clone->{real_column} = $self;

    return $clone;
}

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

1;

__END__