diff Lib/IMPL/Class/PropertyInfo.pm @ 4:e59f44f75f20

DOM - в разработке Testing - по мелочи Property - изменен механизм выбора имплементора
author Sergey
date Wed, 12 Aug 2009 17:36:07 +0400
parents 03e58a454b20
children b544a772b654
line wrap: on
line diff
--- a/Lib/IMPL/Class/PropertyInfo.pm	Tue Aug 11 17:45:52 2009 +0400
+++ b/Lib/IMPL/Class/PropertyInfo.pm	Wed Aug 12 17:36:07 2009 +0400
@@ -6,33 +6,48 @@
 __PACKAGE__->mk_accessors(qw(Type Mutators canGet canSet));
 __PACKAGE__->PassThroughArgs;
 
-our @Implementors = ( ['IMPL::Object' => 'IMPL::Class::Property::Direct'] );
-
 my %LoadedModules;
 
 sub CTOR {
     my $this = shift;
     
-    my $implementor = $this->Implementor($this->SelectImplementor());
-    if (my $class = ref $implementor ? undef : $implementor) {
-        if (not $LoadedModules{$class}) {
-            (my $package = $class.'.pm') =~ s/::/\//g;
-            require $package;
-            $LoadedModules{$class} = 1;
+    $this->Mutators(0) unless defined $this->Mutators;
+}
+
+sub Implementor {
+    my $this = shift;
+    
+    my $implementor;
+    
+    if (@_) {
+        $this->SUPER::Implementor(@_);
+    } else {
+        my $implementor = $this->SUPER::Implementor;
+        return $implementor if $implementor;
+        
+        $implementor = $this->SelectImplementor();
+        
+        if (my $class = ref $implementor ? undef : $implementor) {
+            if (not $LoadedModules{$class}) {
+                (my $package = $class.'.pm') =~ s/::/\//g;
+                require $package;
+                $LoadedModules{$class} = 1;
+            }
         }
+        
+        $this->Implementor($implementor);
+        return $implementor;
     }
     
-    $this->Mutators(0) unless defined $this->Mutators;
 }
 
 sub SelectImplementor {
     my ($this) = @_;
     
-    foreach my $item (@Implementors) {
-        return $item->[1] if $this->Class->isa($item->[0]);
+    if ($this->Class->can('_PropertyImplementor')) {
+        return $this->Class->_PropertyImplementor;
     }
-    
     die new IMPL::Exception('Can\'t find a property implementor for the specified class',$this->Class);
 }
 
-1;
+1;
\ No newline at end of file