/[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

Diff of /lib/A3C/Record.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 74 by dpavlin, Fri Apr 11 15:55:03 2008 UTC revision 240 by dpavlin, Wed Oct 1 19:58:37 2008 UTC
# Line 5  use warnings; Line 5  use warnings;
5    
6  use base 'Jifty::Record';  use base 'Jifty::Record';
7    
8    use Data::Dump qw/dump/;
9    
10  =head1 NAME  =head1 NAME
11    
12  Custom Record class for A3C  Custom Record class for A3C
# Line 25  sub load_or_create { Line 27  sub load_or_create {
27                  ( $self, $class ) = ( $class, undef );                  ( $self, $class ) = ( $class, undef );
28          } else {          } else {
29                  $self = $class->new();                  $self = $class->new();
30      }          }
31    
32          my %args = (@_);          my %args = (@_);
33    
# Line 38  sub load_or_create { Line 40  sub load_or_create {
40    
41          my %load_cols;          my %load_cols;
42    
43          if ( ref($self) eq 'A3C::Model::Person' ) {          if ( ref($self) eq Jifty->app_class('Model','Person') ) {
44    
45                  $load_cols{$_} = $args{$_} foreach ( qw/                  $load_cols{$_} = $args{$_} foreach ( qw/
46                          uid                          uid
# Line 55  sub load_or_create { Line 57  sub load_or_create {
57                  return $self->create(%args);                  return $self->create(%args);
58          }          }
59    
60          return ( $id, $msg );          return ( $self->id, $msg );
61    }
62    
63    =head2 create
64    
65    Serialize ARRAY values into single scalar separated by magic C<< <*> >> marker
66    
67    =cut
68    
69    sub create {
70            #warn "# create",dump(@_);
71            my $self = shift;
72            my %data = @_ or die "no data?";
73            foreach my $col ( keys %data ) {
74                    #warn "## ref($col)=",ref($col);
75                    $data{$col} = join(' <*> ', @{$data{$col}}) if ref( $data{$col} ) eq 'ARRAY';
76            }
77            #warn "## data = ",dump( %data );
78            $self->SUPER::create( %data );
79  }  }
80    
81    
82  1;  1;

Legend:
Removed from v.74  
changed lines
  Added in v.240

  ViewVC Help
Powered by ViewVC 1.1.26