summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search/Condition.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2011-04-02 18:49:04 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2011-04-02 18:49:04 +0200
commitd5c5177f2ef698aefa8aeffaa458016583c20f79 (patch)
treea4cc7750fd3febf12d13cea89a3b1677e38559c6 /Bugzilla/Search/Condition.pm
parent14151ea2f8fb33d4336afa161a0e8b8bed6e5daa (diff)
downloadbugzilla-d5c5177f2ef698aefa8aeffaa458016583c20f79.tar.gz
bugzilla-d5c5177f2ef698aefa8aeffaa458016583c20f79.tar.xz
Bug 640045: Convert Search.pm to use the new AND/OR system internally.
This includes creating new Search::Clause and Search::Condition objects. r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Search/Condition.pm')
-rw-r--r--Bugzilla/Search/Condition.pm66
1 files changed, 66 insertions, 0 deletions
diff --git a/Bugzilla/Search/Condition.pm b/Bugzilla/Search/Condition.pm
new file mode 100644
index 000000000..db20e7f3b
--- /dev/null
+++ b/Bugzilla/Search/Condition.pm
@@ -0,0 +1,66 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is the Bugzilla Bug Tracking System.
+#
+# The Initial Developer of the Original Code is BugzillaSource, Inc.
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Max Kanat-Alexander <mkanat@bugzilla.org>
+
+package Bugzilla::Search::Condition;
+use strict;
+use base qw(Exporter);
+our @EXPORT_OK = qw(condition);
+
+sub new {
+ my ($class, $params) = @_;
+ my %self = %$params;
+ bless \%self, $class;
+ return \%self;
+}
+
+sub field { return $_[0]->{field} }
+sub operator { return $_[0]->{operator} }
+sub value { return $_[0]->{value} }
+
+sub fov {
+ my ($self) = @_;
+ return ($self->field, $self->operator, $self->value);
+}
+
+sub translated {
+ my ($self, $params) = @_;
+ if (@_ == 2) {
+ $self->{translated} = $params;
+ }
+ return $self->{translated};
+}
+
+sub as_string {
+ my ($self) = @_;
+ return $self->translated->{term};
+}
+
+###########################
+# Convenience Subroutines #
+###########################
+
+sub condition {
+ my ($field, $operator, $value) = @_;
+ return __PACKAGE__->new({ field => $field, operator => $operator,
+ value => $value });
+}
+
+1; \ No newline at end of file