[Rt-commit] r2327 - in DBIx-SearchBuilder/trunk: . SearchBuilder
jesse at bestpractical.com
jesse at bestpractical.com
Wed Mar 9 03:38:11 EST 2005
Author: jesse
Date: Wed Mar 9 03:38:09 2005
New Revision: 2327
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
Log:
r6636 at hualien: jesse | 2005-03-09 03:33:24 -0500
Slight refactoring to work around weirdness in perl's debugger
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm Wed Mar 9 03:38:09 2005
@@ -413,78 +413,80 @@
# {{{ sub AUTOLOAD
-sub AUTOLOAD {
- my $self = shift;
-
- no strict 'refs';
-
- if ($AUTOLOAD =~ /.*::(\w+)/o && $self->_Accessible($1,'read') ) {
- my $Attrib = $1;
+sub AUTOLOAD {
+ my $self = shift;
- *{$AUTOLOAD} = sub { return ($_[0]->_Value($Attrib))};
- return($self->_Value($Attrib));
- } elsif ($AUTOLOAD =~ /.*::[sS]et_?(\w+)/o) {
+ no strict 'refs';
+ my $Attrib;
+ if ( $AUTOLOAD =~ /.*::(\w+)/o ) {
+ $Attrib = $1;
+ }
+ if ( $Attrib && $self->_Accessible( $Attrib, 'read' ) ) {
+ *{$AUTOLOAD} = sub { return ( $_[0]->_Value($Attrib) ) };
+ return ( $self->_Value($Attrib) );
+ }
+ elsif ( $AUTOLOAD =~ /.*::[sS]et_?(\w+)/o ) {
+ $Attrib = $1;
- if ($self->_Accessible($1,'write')) {
- my $Attrib = $1;
+ if ( $self->_Accessible( $Attrib, 'write' ) ) {
- *{$AUTOLOAD} = sub {
- return ($_[0]->_Set(Field => $Attrib, Value => $_[1]))
- };
+ *{$AUTOLOAD} = sub {
+ return ( $_[0]->_Set( Field => $Attrib, Value => $_[1] ) );
+ };
- my $Value = shift @_;
- return($self->_Set(Field => $Attrib, Value => $Value));
- }
+ my $Value = shift @_;
+ return ( $self->_Set( Field => $Attrib, Value => $Value ) );
+ }
- elsif ($self->_Accessible($1, 'read')) {
- *{$AUTOLOAD} = sub {
- return (0, 'Immutable field');
- };
- return(0, 'Immutable field');
- }
- else {
- return(0, 'Nonexistant field?');
+ elsif ( $self->_Accessible( $Attrib, 'read' ) ) {
+ *{$AUTOLOAD} = sub {
+ return ( 0, 'Immutable field' );
+ };
+ return ( 0, 'Immutable field' );
+ }
+ else {
+ return ( 0, 'Nonexistant field?' );
+ }
}
- } elsif ($AUTOLOAD =~ /.*::(\w+?)_?[oO]bj$/o) {
- if ($self->_Accessible($1,'object')) {
- my $Attrib = $1;
- *{$AUTOLOAD} = sub {
- my $s = shift;
- return $s->_Object(
- Field => $Attrib,
- Args => [@_],
- );
- };
- return $self->_Object( Field => $Attrib, Args => [@_] );
- } else {
- return(0, 'No object mapping for field');
+ elsif ( $AUTOLOAD =~ /.*::(\w+?)_?[oO]bj$/o ) {
+ $Attrib = $1;
+ if ( $self->_Accessible( $Attrib, 'object' ) ) {
+ *{$AUTOLOAD} = sub {
+ my $s = shift;
+ return $s->_Object(
+ Field => $Attrib,
+ Args => [@_],
+ );
+ };
+ return $self->_Object( Field => $Attrib, Args => [@_] );
+ }
+ else {
+ return ( 0, 'No object mapping for field' );
+ }
}
- }
+ #Previously, I checked for writability here. but I'm not sure that's the
+ #right idea. it breaks the ability to do ValidateQueue for a ticket
+ #on creation.
- #Previously, I checked for writability here. but I'm not sure that's the
- #right idea. it breaks the ability to do ValidateQueue for a ticket
- #on creation.
-
- elsif ($AUTOLOAD =~ /.*::[vV]alidate_?(\w+)/o ) {
- my $Attrib = $1;
-
- *{$AUTOLOAD} = sub { return ($_[0]->_Validate($Attrib, $_[1]))};
- my $Value = shift @_;
- return($self->_Validate($Attrib, $Value));
+ elsif ( $AUTOLOAD =~ /.*::[vV]alidate_?(\w+)/o ) {
+ $Attrib = $1;
+
+ *{$AUTOLOAD} = sub { return ( $_[0]->_Validate( $Attrib, $_[1] ) ) };
+ my $Value = shift @_;
+ return ( $self->_Validate( $Attrib, $Value ) );
+ }
+
+ # TODO: if autoload = 0 or 1 _ then a combination of lowercase and _ chars,
+ # turn them into studlycapped phrases
+
+ else {
+ my ( $package, $filename, $line );
+ ( $package, $filename, $line ) = caller;
+
+ die "$AUTOLOAD Unimplemented in $package. ($filename line $line) \n";
}
-
- # TODO: if autoload = 0 or 1 _ then a combination of lowercase and _ chars,
- # turn them into studlycapped phrases
-
- else {
- my ($package, $filename, $line);
- ($package, $filename, $line) = caller;
-
- die "$AUTOLOAD Unimplemented in $package. ($filename line $line) \n";
- }
-
}
# }}}
More information about the Rt-commit
mailing list