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 },
38 '@{}' => sub { $_[0]->name_parts },
43 The constructor, takes L</loader>, L</name>, L</schema>, and L</ignore_schema>
44 as key-value parameters.
53 croak "loader is required" unless ref $self->{loader};
55 weaken $self->{loader};
57 $self->{_schema} = delete $self->{schema};
59 return bless $self, $class;
64 Make a shallow copy of the object.
71 return bless { %$self }, ref $self;
76 The schema (or owner) of the object. Returns nothing if L</ignore_schema> is
81 Set to true to make L</schema> and L</sql_name> not use the defined L</schema>.
82 Does not affect L</dbic_name> (for
83 L<qualify_objects|DBIx::Class::Schema::Loader::Base/qualify_objects> testing on
91 return $self->_schema(@_) unless $self->ignore_schema;
97 my ($self, $identifier) = @_;
99 $identifier = '' if not defined $identifier;
101 my $qt = $self->loader->quote_char || '';
103 if (length $qt > 1) {
104 my @qt = split //, $qt;
105 return $qt[0] . $identifier . $qt[1];
108 return "${qt}${identifier}${qt}";
113 Returns the properly quoted full identifier with L</schema> and L</name>.
120 my $name_sep = $self->loader->name_sep;
123 return $self->_quote($self->schema)
125 . $self->_quote($self->name);
128 return $self->_quote($self->name);
133 Returns a value suitable for the C<< __PACKAGE__->table >> call in L<DBIx::Class> Result files.
140 my $name_sep = $self->loader->name_sep;
142 if ($self->loader->qualify_objects && $self->_schema) {
143 if ($self->_schema =~ /\W/ || $self->name =~ /\W/) {
144 return \ $self->sql_name;
147 return $self->_schema . $name_sep . $self->name;
150 if ($self->name =~ /\W/) {
151 return \ $self->_quote($self->name);
159 Returns an arrayref of the values returned by the methods specified in
160 the L<moniker_parts|DBIx::Class::Schema::Loader::Base/moniker_parts> of
161 the L</loader> object. The object arrayrefifies to this value.
167 return [ map { $self->$_ } @{$self->loader->moniker_parts} ];
173 L<DBIx::Class::Schema::Loader::Table>, L<DBIx::Class::Schema::Loader>,
174 L<DBIx::Class::Schema::Loader::Base>
178 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
182 This library is free software; you can redistribute it and/or modify it under
183 the same terms as Perl itself.
188 # vim:et sts=4 sw=4 tw=0: