1 package DBIx::Class::Schema::Loader::DBObject;
5 use base 'Class::Accessor::Grouped';
6 use Carp::Clan qw/^DBIx::Class/;
7 use Scalar::Util 'weaken';
12 DBIx::Class::Schema::Loader::DBObject - Base Class for Database Objects Such as
13 Tables and Views in L<DBIx::Class::Schema::Loader>
19 The loader object this object is associated with, this is a required parameter
24 Name of the object. The object stringifies to this value.
28 __PACKAGE__->mk_group_accessors(simple => qw/
36 '""' => sub { $_[0]->name };
40 The constructor, takes L</loader>, L</name>, L</schema>, and L</ignore_schema>
41 as key-value parameters.
50 croak "loader is required" unless ref $self->{loader};
52 weaken $self->{loader};
54 $self->{_schema} = delete $self->{schema};
56 return bless $self, $class;
61 Make a shallow copy of the object.
68 return bless { %$self }, ref $self;
73 The schema (or owner) of the object. Returns nothing if L</ignore_schema> is
78 Set to true to make L</schema> and L</sql_name> not use the defined L</schema>.
79 Does not affect L</dbic_name> (for
80 L<qualify_objects|DBIx::Class::Schema::Loader::Base/qualify_objects> testing on
88 return $self->_schema(@_) unless $self->ignore_schema;
94 my ($self, $identifier) = @_;
96 $identifier = '' if not defined $identifier;
98 my $qt = $self->loader->quote_char || '';
100 if (length $qt > 1) {
101 my @qt = split //, $qt;
102 return $qt[0] . $identifier . $qt[1];
105 return "${qt}${identifier}${qt}";
110 Returns the properly quoted full identifier with L</schema> and L</name>.
117 my $name_sep = $self->loader->name_sep;
120 return $self->_quote($self->schema)
122 . $self->_quote($self->name);
125 return $self->_quote($self->name);
130 Returns a value suitable for the C<< __PACKAGE__->table >> call in L<DBIx::Class> Result files.
137 my $name_sep = $self->loader->name_sep;
139 if ($self->loader->qualify_objects && $self->_schema) {
140 if ($self->_schema =~ /\W/ || $self->name =~ /\W/) {
141 return \ $self->sql_name;
144 return $self->_schema . $name_sep . $self->name;
147 if ($self->name =~ /\W/) {
148 return \ $self->_quote($self->name);
156 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
157 L<DBIx::Class::Schema::Loader::Base>
161 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
165 This library is free software; you can redistribute it and/or modify it under
166 the same terms as Perl itself.
171 # vim:et sts=4 sw=4 tw=0: