/[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.9 by joko, Tue Feb 18 18:35:30 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## --------------------------------------------------------------------------------  ## --------------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.9  2003/02/18 18:35:30  joko
6    ##  + encapsulated/abstracted some more functionality: sub load_single
7    ##
8    ##  Revision 1.8  2003/02/14 14:20:05  joko
9    ##  + modified mixin behaviour
10    ##
11  ##  Revision 1.7  2003/02/11 10:34:19  joko  ##  Revision 1.7  2003/02/11 10:34:19  joko
12  ##  + loaded module may now lack 'mixin::with' declaration  ##  + loaded module may now lack 'mixin::with' declaration
13  ##  + 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 126  sub new { Line 132  sub new {
132    sub load {    sub load {
133    
134      my $self = shift;      my $self = shift;
135        my $modulename = shift;
136        my $options = shift;
137    
138        if (ref $modulename eq 'ARRAY') {
139          foreach (@$modulename) {
140            $self->load_single($_, $options);
141          }
142        } else {
143          $self->load_single($modulename, $options);
144        }
145    
146      }
147    
148      sub load_single {
149    
150        my $self = shift;
151      my $modulename_load = shift;      my $modulename_load = shift;
152    
153      my $options = shift;      my $options = shift;
# Line 163  sub new { Line 185  sub new {
185      #bless $self, $package;      #bless $self, $package;
186    
187      # V2:      # V2:
188        $self->mixinPackage($package);
189        
190        if (my $method = $options->{method}) {
191          $self->$method();
192        }
193    
194        return 1;
195        
196      }
197      
198      sub mixinPackage {
199        my $self = shift;
200        my $package = shift;
201        
202      # switch into foreign package and prepare for mixin      # switch into foreign package and prepare for mixin
203      $self->mixin_prepare($package);      $self->mixin_prepare($package);
204    
205      # 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
206      $self->mixin_do($package);      $self->mixin_do($package);
207    
     if (my $method = $options->{method}) {  
       $self->$method();  
     }  
   
     return 1;  
       
208    }    }
209    
210    # 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.9

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