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 The schema (or owner) of the object. Returns nothing if L</ignore_schema> is
66 Set to true to make L</schema> and L</sql_name> not use the defined L</schema>.
67 Does not affect L</dbic_name> (for
68 L<qualify_objects|DBIx::Class::Schema::Loader::Base/qualify_objects> testing on
76 return $self->_schema(@_) unless $self->ignore_schema;
82 my ($self, $identifier) = @_;
84 $identifier = '' if not defined $identifier;
86 my $qt = $self->loader->quote_char || '';
89 my @qt = split //, $qt;
90 return $qt[0] . $identifier . $qt[1];
93 return "${qt}${identifier}${qt}";
98 Returns the properly quoted full identifier with L</schema> and L</name>.
105 my $name_sep = $self->loader->name_sep;
108 return $self->_quote($self->schema)
110 . $self->_quote($self->name);
113 return $self->_quote($self->name);
118 Returns a value suitable for the C<< __PACKAGE__->table >> call in L<DBIx::Class> Result files.
125 my $name_sep = $self->loader->name_sep;
127 if ($self->loader->qualify_objects && $self->_schema) {
128 if ($self->_schema =~ /\W/ || $self->name =~ /\W/) {
129 return \ $self->sql_name;
132 return $self->_schema . $name_sep . $self->name;
135 if ($self->name =~ /\W/) {
136 return \ $self->_quote($self->name);
144 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
145 L<DBIx::Class::Schema::Loader::Base>
149 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
153 This library is free software; you can redistribute it and/or modify it under
154 the same terms as Perl itself.
159 # vim:et sts=4 sw=4 tw=0: