Newer Older
71 lines | 1.077kb
add DBIx::Custom::Column
yuki-kimoto authored on 2010-02-11
1
package DBIx::Custom::Column;
2

            
3
use strict;
4
use warnings;
5

            
6
use base 'Object::Simple';
7

            
8
__PACKAGE__->attr([qw/column id table/]);
9

            
10
sub parse {
11
    my ($self, $key) = @_;
12
    
13
    $key ||= '';
14
    
15
    unless ($key =~ /\./) {
16
        $self->column($key);
17
        $self->table('');
18
        return $self;
19
    }
20
    
21
    my ($table, $column) = split /\./, $key;
22
    
23
    $self->column($column);
24
    $self->table($table);
25
    
26
    return $self;
27
}
28

            
29
1;
30

            
31
=head1 NAME
32

            
33
DBIx::Custom::Column - DBIx::Custom column
34

            
35
=head1 SYNOPSIS
36
    
37
    # New
38
    my $column = DBIx::Custom::Column->new;
39
    
40
    # Parse
41
    $column->parse('books.author@IDxxx');
42
    
43
    # Attributes
44
    my $name  = $column->name;
45
    my $table = $column->table;
46
    my $id    = $column->id;
47

            
48
=head1 ATTRIBUTES
49

            
50
=head2 id
51

            
52
    $column = $column->id($id);
53
    $id     = $column->id
54

            
55
=head2 name
56

            
57
    $column = $column->name($name);
58
    $name   = $column->name
59

            
60
=head2 table
61

            
62
    $column = $column->table($table);
63
    $table  = $column->table
64

            
65
=head1 METHODS
66

            
67
=head2 parse
68

            
69
    $column->parse('books.author@IDxxx');
70

            
71
=cut