Permalink
Browse files

Added test to prevent recreation of methods

  • Loading branch information...
1 parent 7ce9484 commit da7a46ea5b05bbf8291707851476f7c4ec306f44 @riemann42 committed Apr 14, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/Music/Tag.pm
View
@@ -495,14 +495,15 @@ sub _add_to_namespace {
$readwriter = $reader;
}
$METHODS{$attrname}->{readwriter} = $readwriter;
- if ($readwriter) { *{ $package . '::' . $attrname } = $readwriter; }
+ if ((not defined *{ $package . '::' . $attrname }) && ($readwriter)) { *{ $package . '::' . $attrname } = $readwriter; }
+
}
if ($PBP_METHODS) {
- if ($writer) { *{ $package . '::set_' . $attrname } = $writer; }
- if ($reader) { *{ $package . '::get_' . $attrname } = $reader; }
+ if ((not defined *{ $package . '::set_' . $attrname }) && ($writer)) { *{ $package . '::set_' . $attrname } = $writer; }
+ if ((not defined *{ $package . '::get_' . $attrname }) && ($reader)) { *{ $package . '::get_' . $attrname } = $reader; }
}
if ($TRADITIONAL_METHODS || $PBP_METHODS) {
- if ($predicate) { *{ $package . '::has_' . $attrname } = $predicate; }
+ if ((not defined *{ $package . '::has_' . $attrname }) && ($predicate)) { *{ $package . '::has_' . $attrname } = $predicate; }
}
## use critic
}

0 comments on commit da7a46e

Please sign in to comment.