File: Column.pm

package info (click to toggle)
libalzabo-perl 0.87-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,124 kB
  • ctags: 771
  • sloc: perl: 14,590; makefile: 46
file content (94 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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__

=head1 NAME

Alzabo::Runtime::Column - Column objects

=head1 SYNOPSIS

  use Alzabo::Runtime::Column;

=for pod_merge DESCRIPTION

=head1 INHERITS FROM

C<Alzabo::Column>

=for pod_merge merged

=for pod_merge METHODS

=head2 alias

Takes the following parameters:

=over 4

=item * as => $name

=back

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

=head1 AUTHOR

Dave Rolsky, <autarch@urth.org>

=cut