| 1 | package DBIx::MoCo::Column; | ||||||||||||
| 2 | 12 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 12 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 34 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 6 | 34 | my $class = shift; | |||||||||||
| 7 | 34 | ▶ | my $self = shift || ''; # scalar | ||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 8 | 34 | bless \$self, $class; | |||||||||||
| 9 | } | ||||||||||||
| 10 | |||||||||||||
| 11 | 12 | 1; | |||||||||||
| 12 | |||||||||||||
| 13 | =head1 NAME | ||||||||||||
| 14 | |||||||||||||
| 15 | DBIx::MoCo::Column - Scalar blessed class for inflating columns. | ||||||||||||
| 16 | |||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||
| 18 | |||||||||||||
| 19 | Inflate column value by using DBIx::MoCo::Column::* plugins. | ||||||||||||
| 20 | If you set up your plugin like this, | ||||||||||||
| 21 | |||||||||||||
| 22 | package DBIx::MoCo::Column::URI; | ||||||||||||
| 23 | |||||||||||||
| 24 | sub URI { | ||||||||||||
| 25 | my $self = shift; | ||||||||||||
| 26 | return URI->new($$self); | ||||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | sub URI_as_string { | ||||||||||||
| 30 | my $class = shift; | ||||||||||||
| 31 | my $uri = shift or return; | ||||||||||||
| 32 | return $uri->as_string; | ||||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 1; | ||||||||||||
| 36 | |||||||||||||
| 37 | Then, you can use column_as_MyColumn method as following, | ||||||||||||
| 38 | |||||||||||||
| 39 | my $e = MyEntry->retrieve(..); | ||||||||||||
| 40 | print $e->uri; # 'http://test.com/test' | ||||||||||||
| 41 | print $e->uri_as_URI->host; # 'test.com'; | ||||||||||||
| 42 | |||||||||||||
| 43 | my $uri = URI->new('http://www.test.com/test'); | ||||||||||||
| 44 | $e->uri_as_URI($uri); # set uri by using URI instance | ||||||||||||
| 45 | |||||||||||||
| 46 | The name of infrate method which will be imported must be same as the package name. | ||||||||||||
| 47 | |||||||||||||
| 48 | If you don't define "as string" method (such as URI_as_string), | ||||||||||||
| 49 | scalar evaluated value of given argument will be used for new value instead. | ||||||||||||
| 50 | |||||||||||||
| 51 | =head1 SEE ALSO | ||||||||||||
| 52 | |||||||||||||
| 53 | L<DBIx::MoCo>, L<DBIx::MoCo::Column::URI> | ||||||||||||
| 54 | |||||||||||||
| 55 | =head1 AUTHOR | ||||||||||||
| 56 | |||||||||||||
| 57 | Junya Kondo, E<lt>jkondo@hatena.comE<gt> | ||||||||||||
| 58 | |||||||||||||
| 59 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 60 | |||||||||||||
| 61 | Copyright (C) Hatena Inc. All Rights Reserved. | ||||||||||||
| 62 | |||||||||||||
| 63 | This library is free software; you may redistribute it and/or modify | ||||||||||||
| 64 | it under the same terms as Perl itself. | ||||||||||||
| 65 | |||||||||||||
| 66 | =cut | ||||||||||||