/[cvs]/nfo/perl/libs/Data/Mungle/Transform/Deep.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Mungle/Transform/Deep.pm

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

revision 1.13 by joko, Fri Feb 21 01:48:50 2003 UTC revision 1.14 by jonen, Sat Feb 22 17:13:55 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ---------------------------------------------------------------------------  ## ---------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.14  2003/02/22 17:13:55  jonen
6    ##  + added function 'childObject2string()' to encode 'child'-references to option related string
7    ##  + use new option at 'expand()' for replacing 'childObject2string'
8    ##
9  ##  Revision 1.13  2003/02/21 01:48:50  joko  ##  Revision 1.13  2003/02/21 01:48:50  joko
10  ##  renamed core function  ##  renamed core function
11  ##  ##
# Line 155  sub expand { Line 159  sub expand {
159        my $item;        my $item;
160        # if current item is a reference ...        # if current item is a reference ...
161        if (ref $_[0]) {        if (ref $_[0]) {
162          # ... expand structure recursively          $item = $_[0];
163          $item = expand($_[0], $options);          # if $options->{childObj2string} is TRUE or STRING don't expand referenced object,
164            # instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> )
165            if ($item && $options->{childObj2string}) {
166              $item = childObj2string($item, $options->{childObj2string});
167            } else {
168              # ... expand structure recursively
169              $item = expand($_[0], $options);
170            }
171          # destroy item via seperate callback method (a POST) if requested          # destroy item via seperate callback method (a POST) if requested
172          #$options->{cb}->{destroy}->($_[0]) if $options->{destroy};          #$options->{cb}->{destroy}->($_[0]) if $options->{destroy};
173    
# Line 185  sub expand { Line 196  sub expand {
196                
197        # if current item is a reference ...        # if current item is a reference ...
198        if (ref $_[1]) {        if (ref $_[1]) {
199          # ... expand structure recursively          $item = $_[1];
200          $item = expand($_[1], $options);          # if $options->{childObj2string} is TRUE or STRING don't expand referenced object,
201            # instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> )
202            if ($item && $options->{childObj2string} && !(ref $_[1] eq "ARRAY") && !(ref $_[1] eq "HASH")) {
203              $item = childObj2string($item, $options->{childObj2string});
204            } else {
205              # ... expand structure recursively
206              $item = expand($_[1], $options);
207            }
208          # destroy item via seperate callback method (a POST) if requested          # destroy item via seperate callback method (a POST) if requested
209          #$options->{cb}->{destroy}->($_[1]) if $options->{destroy};          #$options->{cb}->{destroy}->($_[1]) if $options->{destroy};
210                
# Line 458  sub deep_copy { Line 476  sub deep_copy {
476  }  }
477    
478    
479    sub childObj2string {
480      my $obj = shift;
481      my $option = shift;
482      my $classname = ref $obj;
483      
484      if($option == 1) {
485        my $string = "o_" . $classname . "_" .$obj->{guid};
486        return $string;
487      }  
488    }
489    
490    
491  1;  1;
492  __END__  __END__

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed