blib/lib/DBIx/Class/Schema/Loader/DBObject/Informix.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 70 CC 5 SCAR 17.1
CC
5
Cov
0%
dbic_name
12.0
database
6.0
sql_name
6.0
CRAP 5.5
1 package DBIx::Class::Schema::Loader::DBObject::Informix;
2  
3 use strict;
4 use warnings;
5 use base 'DBIx::Class::Schema::Loader::DBObject';
6 use mro 'c3';
7 use namespace::clean;
8  
9 =head1 NAME
10  
11 DBIx::Class::Schema::Loader::DBObject::Informix - Class for Database Objects for
12 Informix Such as Tables and Views in L<DBIx::Class::Schema::Loader>
13  
14 =head1 DESCRIPTION
15  
16 This is a subclass of L<DBIx::Class::Schema::Loader::DBObject> that adds
17 support for fully qualified objects in Informix including both L</database>
18 and L<schema|DBIx::Class::Schema::Loader::DBObject/schema> of the form:
19  
20 database:owner.object_name
21  
22 =head1 METHODS
23  
24 =head2 database
25  
26 The database name this object belongs to.
27  
28 Returns undef if
29 L<ignore_schema|DBIx::Class::Schema::Loader::DBObject/ignore_schema> is set.
30  
31 =cut
32  
33 __PACKAGE__->mk_group_accessors(simple => qw/
34 _database
35 /);
36  
37 sub new {
38 my $class = shift;
39  
40 my $self = $class->next::method(@_);
41  
42 $self->{_database} = delete $self->{database};
43  
44 return $self;
45 }
46  
47 sub database {
48 my $self = shift;
49  
50 return $self->_database(@_) unless $self->ignore_schema;
51  
52 return undef;
53 }
54  
55 =head1 sql_name
56  
57 Returns the properly quoted full identifier with L</database>,
58 L<schema|DBIx::Class::Schema::Loader::DBObject/schema> and
59 L<name|DBIx::Class::Schema::Loader::DBObject/name>.
60  
61 =cut
62  
63 sub sql_name {
64 my $self = shift;
65  
66 my $name_sep = $self->loader->name_sep;
67  
68 if ($self->database) {
69 return $self->_quote($self->database)
70 . ':'
71 . $self->_quote($self->schema)
72 . $name_sep
73 . $self->_quote($self->name);
74 }
75  
76 return $self->next::method(@_);
77 }
78  
79 sub dbic_name {
80 my $self = shift;
81  
82 my $name_sep = $self->loader->name_sep;
83  
84 if ($self->loader->qualify_objects && $self->_database) {
85 if ($self->_database =~ /\W/
86 || $self->_schema =~ /\W/ || $self->name =~ /\W/) {
87  
88 return \ $self->sql_name;
89 }
90  
91 return $self->_database . ':' . $self->_schema . $name_sep . $self->name;
92 }
93  
94 return $self->next::method(@_);
95 }
96  
97 =head1 SEE ALSO
98  
99 L<DBIx::Class::Schema::Loader::Table::Informix>,
100 L<DBIx::Class::Schema::Loader::DBObject>,
101 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
102 L<DBIx::Class::Schema::Loader::Base>
103  
104 =head1 AUTHORS
105  
106 See L<DBIx::Class::Schema::Loader/AUTHORS>.
107  
108 =head1 LICENSE
109  
110 This library is free software; you can redistribute it and/or modify it under
111 the same terms as Perl itself.
112  
113 =cut
114  
115 1;
116 # vim:et sts=4 sw=4 tw=0: