Changeset 6 for LATMOS-Accounts
- Timestamp:
- 02/27/09 19:00:29 (15 years ago)
- Location:
- LATMOS-Accounts
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r5 r6 40 40 if ($@) { return } # error message ? 41 41 return "LATMOS::Accounts::Bases::$pclass"->new(%options); 42 } 43 44 sub _load_obj_class { 45 my ($self, $otype) = @_; 46 47 # finding perl class: 48 my $pclass = ref $self; 49 $pclass .= '::' . ucfirst(lc($otype)); 50 eval "require $pclass;"; 51 if ($@) { return } # error message ? 52 return $pclass; 53 } 54 55 =head2 list_canonicals_fields($otype) 56 57 Return the list of supported fields by the database for object type $otype. 58 59 =cut 60 61 sub list_canonicals_fields { 62 my ($self, $otype) = @_; 63 my $pclass = $self->_load_obj_class($otype) or return; 64 $pclass->canonical_fields; 42 65 } 43 66 -
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r3 r6 33 33 34 34 # finding perl class: 35 my $pclass = ref $base; 36 $pclass .= '::' . ucfirst(lc($otype)); 37 eval "require $pclass;"; 38 if ($@) { return } # error message ? 35 my $pclass = $base->_load_obj_class($otype) or return; 39 36 my $newobj = "$pclass"->new($base, $id, @args); 40 37 $newobj->{_base} = $base; … … 52 49 } 53 50 54 # Preloaded methods go here. 51 =head2 canonical_fields 52 53 Must return the list of field supported by the object. 54 55 If exists, _canonicals_fields function is called. 56 57 Notice this query will always come from the upstream data base, 58 this function is just a ficility to store data in the module, but the 59 underling database can reply themself. 60 61 See list_canonical_fields(). 62 63 =cut 64 65 sub canonical_fields { 66 my ($self) = @_; 67 if ($self->can('_canonical_fields')) { 68 $self->_canonical_fields; 69 } else { return; } 70 } 55 71 56 72 1; 57 73 58 74 __END__ 75 76 =head1 CANICALS FIELDS 77 78 =head2 User class 79 80 =head2 Group class 59 81 60 82 =head1 SEE ALSO -
LATMOS-Accounts/t/10_bases.t
r3 r6 1 1 use strict; 2 2 use warnings; 3 use Test::More tests => 1 1;3 use Test::More tests => 12; 4 4 5 5 use_ok('LATMOS::Accounts::Bases'); … … 16 16 isa_ok($user, 'LATMOS::Accounts::Bases::Dummy::User'); 17 17 18 ok(eq_set([ $dummyb->list_canonicals_fields('user') ], []), "Can get canonicals fields"); 18 19 ok(!$dummyb->is_transactionnal, 'Dummy driver is not transactionnal');
Note: See TracChangeset
for help on using the changeset viewer.