From f0b6242097e487198de559d39d4169a2a0a4d8e7 Mon Sep 17 00:00:00 2001 From: Tiago Mello Date: Thu, 10 Feb 2011 23:31:28 -0200 Subject: Bug 620827: Refactor remove see also to use remove_from_db instead. r/a=mkanat --- Bugzilla/BugUrl.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Bugzilla/BugUrl.pm') diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 521ee8193..f4f0e410b 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -40,6 +40,7 @@ use constant DB_COLUMNS => qw( id bug_id value + class ); # This must be strings with the names of the validations, @@ -48,6 +49,7 @@ use constant DB_COLUMNS => qw( use constant VALIDATORS => { value => '_check_value', bug_id => '_check_bug_id', + class => \&_check_class, }; # This is the order we go through all of subclasses and @@ -61,6 +63,13 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::Debian ); +############################### +#### Accessors ###### +############################### + +sub class { return $_[0]->{class} } +sub bug_id { return $_[0]->{bug_id} } + ############################### #### Methods #### ############################### @@ -92,6 +101,18 @@ sub new { return $class->SUPER::new(@_); } +sub _do_list_select { + my $class = shift; + my $objects = $class->SUPER::_do_list_select(@_); + + foreach my $object (@$objects) { + eval "use " . $object->class; die $@ if $@; + bless $object, $object->class; + } + + return $objects +} + # This is an abstract method. It must be overridden # in every subclass. sub should_handle { @@ -115,6 +136,12 @@ sub class_for { reason => 'show_bug' }); } +sub _check_class { + my ($class, $subclass) = @_; + eval "use $subclass"; die $@ if $@; + return $subclass; +} + sub _check_bug_id { my ($class, $bug_id) = @_; -- cgit v1.2.3-24-g4f1b