/[A3C]/lib/A3C/Record.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/A3C/Record.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 76 - (show annotations)
Fri Apr 11 16:50:37 2008 UTC (15 years, 11 months ago) by dpavlin
File size: 961 byte(s)
fix indent

1 package A3C::Record;
2
3 use strict;
4 use warnings;
5
6 use base 'Jifty::Record';
7
8 =head1 NAME
9
10 Custom Record class for A3C
11
12 =head1 METHODS
13
14 =head2 load_or_create
15
16 Perform canonicalization on C<load_or_create> and loads subset of columns
17 (which hopfully are indexes in model for performance reasons).
18
19 =cut
20
21 sub load_or_create {
22 my $class = shift;
23 my $self;
24 if ( ref($class) ) {
25 ( $self, $class ) = ( $class, undef );
26 } else {
27 $self = $class->new();
28 }
29
30 my %args = (@_);
31
32 foreach my $key ( keys %args ) {
33 $args{$key} = $self->run_canonicalization_for_column(
34 column => $key,
35 value => $args{$key}
36 );
37 }
38
39 my %load_cols;
40
41 if ( ref($self) eq Jifty->app_class('Model','Person') ) {
42
43 $load_cols{$_} = $args{$_} foreach ( qw/
44 uid
45 hrEduPersonUniqueID
46 mail
47 / );
48
49 } else {
50 %load_cols = %args;
51 }
52
53 my ( $id, $msg ) = $self->load_by_cols(%load_cols);
54 unless ( $self->id ) {
55 return $self->create(%args);
56 }
57
58 return ( $id, $msg );
59 }
60
61 1;

  ViewVC Help
Powered by ViewVC 1.1.26