[Rt-commit] r9266 - rt/branches/3.7-RTIR-RELENG/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 10 21:13:30 EDT 2007


Author: ruz
Date: Wed Oct 10 21:13:29 2007
New Revision: 9266

Modified:
   rt/branches/3.7-RTIR-RELENG/lib/RT/Record.pm

Log:
::Record::_BuildTableAttributes()
* now it works as a class method too
* get rid of code duplication

Modified: rt/branches/3.7-RTIR-RELENG/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.7-RTIR-RELENG/lib/RT/Record.pm	(original)
+++ rt/branches/3.7-RTIR-RELENG/lib/RT/Record.pm	Wed Oct 10 21:13:29 2007
@@ -659,6 +659,7 @@
 
 sub _BuildTableAttributes {
     my $self = shift;
+    my $class = ref($self) || $self;
 
     my $attributes;
     if ( UNIVERSAL::can( $self, '_CoreAccessible' ) ) {
@@ -670,37 +671,19 @@
 
     foreach my $column (%$attributes) {
         foreach my $attr ( %{ $attributes->{$column} } ) {
-            $_TABLE_ATTR->{ref($self)}->{$column}->{$attr} = $attributes->{$column}->{$attr};
+            $_TABLE_ATTR->{$class}->{$column}->{$attr} = $attributes->{$column}->{$attr};
         }
     }
-    if ( UNIVERSAL::can( $self, '_OverlayAccessible' ) ) {
-        $attributes = $self->_OverlayAccessible();
+    foreach my $method ( qw(_OverlayAccessible _VendorAccessible _LocalAccessible) ) {
+        next unless UNIVERSAL::can( $self, $method );
+        $attributes = $self->$method();
 
         foreach my $column (%$attributes) {
             foreach my $attr ( %{ $attributes->{$column} } ) {
-                $_TABLE_ATTR->{ref($self)}->{$column}->{$attr} = $attributes->{$column}->{$attr};
+                $_TABLE_ATTR->{$class}->{$column}->{$attr} = $attributes->{$column}->{$attr};
             }
         }
     }
-    if ( UNIVERSAL::can( $self, '_VendorAccessible' ) ) {
-        $attributes = $self->_VendorAccessible();
-
-        foreach my $column (%$attributes) {
-            foreach my $attr ( %{ $attributes->{$column} } ) {
-                $_TABLE_ATTR->{ref($self)}->{$column}->{$attr} = $attributes->{$column}->{$attr};
-            }
-        }
-    }
-    if ( UNIVERSAL::can( $self, '_LocalAccessible' ) ) {
-        $attributes = $self->_LocalAccessible();
-
-        foreach my $column (%$attributes) {
-            foreach my $attr ( %{ $attributes->{$column} } ) {
-                $_TABLE_ATTR->{ref($self)}->{$column}->{$attr} = $attributes->{$column}->{$attr};
-            }
-        }
-    }
-
 }
 
 


More information about the Rt-commit mailing list