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

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

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

revision 1.5 by joko, Sun Feb 9 16:24:46 2003 UTC revision 1.6 by joko, Tue Feb 11 11:04:27 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ---------------------------------------------------------------------------  ## ---------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.6  2003/02/11 11:04:27  joko
6    ##  + metadata (args, caller, etc.) are now stored inside {__bridge}
7    ##
8  ##  Revision 1.5  2003/02/09 16:24:46  joko  ##  Revision 1.5  2003/02/09 16:24:46  joko
9  ##  + pseudo constructor mechanism by calling method 'constructor' on object instantiation  ##  + pseudo constructor mechanism by calling method 'constructor' on object instantiation
10  ##  ##
# Line 86  sub new { Line 89  sub new {
89    # mixin arguments    # mixin arguments
90    $self = { @args };    $self = { @args };
91        
92    # mixin seperate    # scan for arguments prefixed by a double underscore '__'
93    $self->{'__arg'} = $seperate if $seperate;    foreach (keys %$self) {
94        if (/^__(.+?)$/) {
95          $self->{__bridge}->{$1} = $self->{$_};
96          delete $self->{$_};
97        }
98      }
99      
100      # mixin seperate - FIXME: should this not be done after blessing?
101      $self->{__bridge}->{'arg'} = $seperate if $seperate;
102    
103    # ... bless hash into object using classname    # ... bless hash into object using classname
104    bless $self, $class;    bless $self, $class;
105    
106    # remember the caller    # remember the caller
107      $self->{'__caller'} = caller;      $self->{__bridge}->{caller_module}  = caller;
108      #print Dumper(caller(2));      #print Dumper(caller(2));
109      #exit;      #exit;
110    
111    $self->{__classname} = $classname;    $self->{__bridge}->{class_name} = $classname;
112    
113      # patches for backward compatibility
114        $self->{'__arg'} = $self->{__bridge}->{'arg'} if $self->{__bridge}->{'arg'};
115        $self->{'__caller'} = $self->{__bridge}->{caller_module} if $self->{__bridge}->{caller_module};
116        $self->{'__classname'} = $self->{__bridge}->{class_name} if $self->{__bridge}->{class_name};
117    
118    $self->_init() if $self->can('_init');    $self->_init() if $self->can('_init');
119    $self->constructor() if $self->can('constructor');    $self->constructor() if $self->can('constructor');
120    
121      # trace
122        #print Dumper($self);
123        #exit;
124    
125    return $self;    return $self;
126  }    }  
127    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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