| 1 | |||
| 2 | =head1 Name | ||
| 3 | |||
| 4 | QBit::Application::Model::DB::Class | ||
| 5 | |||
| 6 | =head1 Description | ||
| 7 | |||
| 8 | Base class for DB modules. | ||
| 9 | |||
| 10 | =cut | ||
| 11 | |||
| 12 | package QBit::Application::Model::DB::Class; | ||
| 13 | $QBit::Application::Model::DB::Class::VERSION = '0.030'; | ||
| 14 | use qbit; | ||
| 15 | |||
| 16 | use base qw(QBit::Class); | ||
| 17 | |||
| 18 | =head1 RO accessors | ||
| 19 | |||
| 20 | =over | ||
| 21 | |||
| 22 | =item * | ||
| 23 | |||
| 24 | B<db> | ||
| 25 | |||
| 26 | =back | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | __PACKAGE__->mk_ro_accessors(qw(db)); | ||
| 31 | |||
| 32 | =head1 Package methods | ||
| 33 | |||
| 34 | =head2 init | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | sub init { | ||
| 39 | my ($self) = @_; | ||
| 40 | |||
| 41 | $self->SUPER::init(); | ||
| 42 | |||
| 43 | throw gettext('Required opt "db" must be QBit::Application::Model::DB descendant') | ||
| 44 | unless $self->db && $self->db->isa('QBit::Application::Model::DB'); | ||
| 45 | |||
| 46 | weaken($self->{'db'}); | ||
| 47 | } | ||
| 48 | |||
| 49 | =head2 quote | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | sub quote { | ||
| 54 | my ($self, $name) = @_; | ||
| 55 | |||
| 56 | return $self->db->quote($name); | ||
| 57 | } | ||
| 58 | |||
| 59 | =head2 quote_identifier | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | sub quote_identifier { | ||
| 64 | my ($self, $name) = @_; | ||
| 65 | |||
| 66 | return $self->db->quote_identifier($name); | ||
| 67 | } | ||
| 68 | |||
| 69 | =head2 filter | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | sub filter {shift->db->filter(@_)} | ||
| 74 | |||
| 75 | TRUE; | ||
| 76 | |||
| 77 | =pod | ||
| 78 | |||
| 79 | For more information see code and test. | ||
| 80 | |||
| 81 | =cut |