1 package DBIx::Class::Schema::Loader::DBObject;
5 use base 'Class::Accessor::Grouped';
7 use Carp::Clan qw/^DBIx::Class/;
8 use Scalar::Util 'weaken';
13 DBIx::Class::Schema::Loader::DBObject - Base Class for Database Objects Such as
14 Tables and Views in L<DBIx::Class::Schema::Loader>
20 The loader object this object is associated with, this is a required parameter
25 Name of the object. The object stringifies to this value.
29 __PACKAGE__->mk_group_accessors(simple => qw/
37 '""' => sub { $_[0]->name };
41 The constructor, takes L</loader>, L</name>, L</schema>, and L</ignore_schema>
42 as key-value parameters.
51 croak "loader is required" unless ref $self->{loader};
53 weaken $self->{loader};
55 $self->{_schema} = delete $self->{schema};
57 return bless $self, $class;
62 Make a shallow copy of the object.
69 return bless { %$self }, ref $self;
74 The schema (or owner) of the object. Returns nothing if L</ignore_schema> is
79 Set to true to make L</schema> and L</sql_name> not use the defined L</schema>.
80 Does not affect L</dbic_name> (for
81 L<qualify_objects|DBIx::Class::Schema::Loader::Base/qualify_objects> testing on
89 return $self->_schema(@_) unless $self->ignore_schema;
95 my ($self, $identifier) = @_;
97 $identifier = '' if not defined $identifier;
99 my $qt = $self->loader->quote_char || '';
101 if (length $qt > 1) {
102 my @qt = split //, $qt;
103 return $qt[0] . $identifier . $qt[1];
106 return "${qt}${identifier}${qt}";
111 Returns the properly quoted full identifier with L</schema> and L</name>.
118 my $name_sep = $self->loader->name_sep;
121 return $self->_quote($self->schema)
123 . $self->_quote($self->name);
126 return $self->_quote($self->name);
131 Returns a value suitable for the C<< __PACKAGE__->table >> call in L<DBIx::Class> Result files.
138 my $name_sep = $self->loader->name_sep;
140 if ($self->loader->qualify_objects && $self->_schema) {
141 if ($self->_schema =~ /\W/ || $self->name =~ /\W/) {
142 return \ $self->sql_name;
145 return $self->_schema . $name_sep . $self->name;
148 if ($self->name =~ /\W/) {
149 return \ $self->_quote($self->name);
157 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
158 L<DBIx::Class::Schema::Loader::Base>
162 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
166 This library is free software; you can redistribute it and/or modify it under
167 the same terms as Perl itself.
172 # vim:et sts=4 sw=4 tw=0: