/[cvs]/nfo/perl/libs/DesignPattern/Bridge.pm
ViewVC logotype

Diff of /nfo/perl/libs/DesignPattern/Bridge.pm

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

revision 1.7 by joko, Tue Feb 11 10:34:19 2003 UTC revision 1.10 by joko, Thu Feb 20 20:50:32 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## --------------------------------------------------------------------------------  ## --------------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.10  2003/02/20 20:50:32  joko
6    ##  + small exception handling: now inheriting from little Exception object
7    ##
8    ##  Revision 1.9  2003/02/18 18:35:30  joko
9    ##  + encapsulated/abstracted some more functionality: sub load_single
10    ##
11    ##  Revision 1.8  2003/02/14 14:20:05  joko
12    ##  + modified mixin behaviour
13    ##
14  ##  Revision 1.7  2003/02/11 10:34:19  joko  ##  Revision 1.7  2003/02/11 10:34:19  joko
15  ##  + loaded module may now lack 'mixin::with' declaration  ##  + loaded module may now lack 'mixin::with' declaration
16  ##  + this gets us the possibility to load modules from any perl namespace  ##  + this gets us the possibility to load modules from any perl namespace
# Line 34  package DesignPattern::Bridge; Line 43  package DesignPattern::Bridge;
43  use strict;  use strict;
44  use warnings;  use warnings;
45    
46  use base qw( DesignPattern::Object );  use base qw(
47      DesignPattern::Object
48      DesignPattern::Exception
49    );
50    
51  use Data::Dumper;  use Data::Dumper;
52    
# Line 126  sub new { Line 138  sub new {
138    sub load {    sub load {
139    
140      my $self = shift;      my $self = shift;
141        my $modulename = shift;
142        my $options = shift;
143    
144        if (ref $modulename eq 'ARRAY') {
145          foreach (@$modulename) {
146            $self->load_single($_, $options);
147          }
148        } else {
149          $self->load_single($modulename, $options);
150        }
151    
152      }
153    
154      sub load_single {
155    
156        my $self = shift;
157      my $modulename_load = shift;      my $modulename_load = shift;
158    
159      my $options = shift;      my $options = shift;
# Line 143  sub new { Line 171  sub new {
171    
172      # this is the module testing phase - use mixin doesn't seem to propagate errors by default      # this is the module testing phase - use mixin doesn't seem to propagate errors by default
173      eval("use $package;");      eval("use $package;");
174        $self->checkExceptions();
175        
176    =pod    
177      if ($@) {      if ($@) {
178        $meta->{loaded}->{$package} = 0;        $meta->{loaded}->{$package} = 0;
179        # include caller information        # include caller information
# Line 155  sub new { Line 186  sub new {
186          print $msg, "\n";          print $msg, "\n";
187        }        }
188      }      }
189    =cut
190    
191  #print "ref-1: ", ref $self, "\n";  #print "ref-1: ", ref $self, "\n";
192  #print "ref-2: ", ref $self::SUPER, "\n";  #print "ref-2: ", ref $self::SUPER, "\n";
# Line 163  sub new { Line 195  sub new {
195      #bless $self, $package;      #bless $self, $package;
196    
197      # V2:      # V2:
198        $self->mixinPackage($package);
199        
200        if (my $method = $options->{method}) {
201          $self->$method();
202        }
203    
204        return 1;
205        
206      }
207      
208      sub mixinPackage {
209        my $self = shift;
210        my $package = shift;
211        
212      # switch into foreign package and prepare for mixin      # switch into foreign package and prepare for mixin
213      $self->mixin_prepare($package);      $self->mixin_prepare($package);
214    
215      # switch into local package (scope which uses DesignPattern::Bridge) and mixin plugin-module      # switch into local package (scope which uses DesignPattern::Bridge) and mixin plugin-module
216      $self->mixin_do($package);      $self->mixin_do($package);
217    
     if (my $method = $options->{method}) {  
       $self->$method();  
     }  
   
     return 1;  
       
218    }    }
219    
220    # TODO: maybe refactor to DesignPattern::Object? what about the '$logger'?    # TODO: maybe refactor to DesignPattern::Object? what about the '$logger'?

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.10

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