| 1 | package CatalystX::CRUD::Object::RDBO; | ||
| 2 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use base qw( CatalystX::CRUD::Object ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | # help for serialize() | ||
| 7 | 3 | ▶ | use Rose::DB::Object::Helpers qw( column_values_as_json ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | ▶ | use JSON; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 3 | our $VERSION = '0.304'; | |
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | CatalystX::CRUD::Object::RDBO - Rose::DB::Object implementation of CatalystX::CRUD::Object | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | # fetch a row from MyApp::Model::Foo (which isa CatalystX::CRUD::Model) | ||
| 19 | my $foo = $c->model('Foo')->fetch( id => 1234 ); | ||
| 20 | $foo->create; | ||
| 21 | $foo->read; | ||
| 22 | $foo->update; | ||
| 23 | $foo->delete; | ||
| 24 | |||
| 25 | =head1 DESCRIPTION | ||
| 26 | |||
| 27 | CatalystX::CRUD::Object::RDBO implements the required CRUD methods | ||
| 28 | of a CatalystX::CRUD::Object subclass. It is intended for use | ||
| 29 | with CatalystX::CRUD::Model::RDBO. | ||
| 30 | |||
| 31 | =head1 METHODS | ||
| 32 | |||
| 33 | Only new or overridden methods are documented here. | ||
| 34 | |||
| 35 | =head2 load_speculative | ||
| 36 | |||
| 37 | Calls load( speculative => 1 ) on the internal delegate() value. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | # convenience methods | ||
| 42 | 0 | ▶ | sub load_speculative { |
|
Subroutine
load_speculative: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 43 | 0 | shift->delegate->load( speculative => 1, @_ ); | |
| 44 | } | ||
| 45 | |||
| 46 | =head2 create | ||
| 47 | |||
| 48 | Calls delegate->save(). | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | # required methods | ||
| 53 | 0 | ▶ | sub create { |
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 54 | 0 | shift->delegate->save(@_); | |
| 55 | } | ||
| 56 | |||
| 57 | =head2 read | ||
| 58 | |||
| 59 | Calls delegate->load(). B<NOTE:> If you need a speculative load, | ||
| 60 | use load_speculative() instead. | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | 10 | ▶ | sub read { |
|
Subroutine
read: called CC=1 SCAR=0.0
Pod
documented
| |||
| 65 | |||
| 66 | # because of the abusive way RDBO handles load() internally, | ||
| 67 | # must re-assign to delegate afterwards. This fixes esp the issue | ||
| 68 | # of passing 'with' => 'rel' to load(). | ||
| 69 | |||
| 70 | 10 | my $cxcobj = shift; | |
| 71 | 10 | my $rdbo = $cxcobj->delegate; | |
| 72 | 10 | $rdbo->load(@_); | |
| 73 | 10 | $cxcobj->{delegate} = $rdbo; | |
| 74 | 10 | return $cxcobj; | |
| 75 | } | ||
| 76 | |||
| 77 | =head2 update | ||
| 78 | |||
| 79 | Calls delegate->save(). | ||
| 80 | |||
| 81 | =cut | ||
| 82 | |||
| 83 | 0 | ▶ | sub update { |
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 84 | 0 | shift->delegate->save(@_); | |
| 85 | } | ||
| 86 | |||
| 87 | =head2 delete | ||
| 88 | |||
| 89 | Calls delegate->delete(@_). | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | 0 | ▶ | sub delete { |
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 94 | 0 | shift->delegate->delete(@_); | |
| 95 | } | ||
| 96 | |||
| 97 | =head2 is_new | ||
| 98 | |||
| 99 | Calls not_found() on the RDBO delegate. | ||
| 100 | |||
| 101 | =cut | ||
| 102 | |||
| 103 | 1 | ▶ | sub is_new { |
|
Subroutine
is_new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 104 | 1 | shift->delegate->not_found(); | |
| 105 | } | ||
| 106 | |||
| 107 | =head2 serialize | ||
| 108 | |||
| 109 | Returns column/value pairs for RDBO delegate with all DateTime | ||
| 110 | et al objects serialized to strings. | ||
| 111 | |||
| 112 | =cut | ||
| 113 | |||
| 114 | 6 | ▶ | sub serialize { |
|
Subroutine
serialize: called CC=1 SCAR=0.0
Pod
documented
| |||
| 115 | 6 | return decode_json( column_values_as_json( shift->delegate ) ); | |
| 116 | } | ||
| 117 | |||
| 118 | 3 | 1; | |
| 119 | |||
| 120 | __END__ | ||