File: Column.pm

package info (click to toggle)
libdbix-class-schema-loader-perl 0.07049-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,464 kB
  • sloc: perl: 11,469; sh: 544; makefile: 4
file content (67 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (4)
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
package DBIx::Class::Schema::Loader::Column;

use strict;
use warnings;
use base 'Class::Accessor::Grouped';
use mro 'c3';
use Carp::Clan qw/^DBIx::Class/;
use Scalar::Util 'weaken';
use namespace::clean;

=head1 NAME

DBIx::Class::Schema::Loader::Column - Class for Columns in
L<DBIx::Class::Schema::Loader>

=head1 DESCRIPTION

Used for representing columns in
L<DBIx::Class::Schema::Loader::Base/col_accessor_map>.

Stringifies to L</name>, and arrayrefifies to the
L<name_parts|DBIx::Class::Schema::Loader::Table/name_parts> of
L</table> plus L</name>.

=cut

__PACKAGE__->mk_group_accessors(simple => qw/
    table
    name
/);

use overload
    '""' => sub { $_[0]->name },
    '@{}' => sub { [ @{$_[0]->table->name_parts}, $_[0]->name ] },
    fallback => 1;

=head1 METHODS

=head2 new

The constructor. Takes L</table> and L</name> key-value parameters.

=cut

sub new {
    my $class = shift;

    my $self = { @_ };
    croak "table is required" unless ref $self->{table};

    weaken $self->{table};

    return bless $self, $class;
}

=head2 table

The L</DBIx::Class::Schema::Loader::Table> object this column belongs to.
Required parameter for L</new>

=head2 name

The name of the column. Required parameter for L</new>.

=cut

1;