Commit 5f88fd5b authored by Tristan Cavelier's avatar Tristan Cavelier

queries: removing uneeded attribute + fix scope bug

parent 608513da
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* @param {String} [spec.operator="AND"] The compare method to use * @param {String} [spec.operator="AND"] The compare method to use
* @param {String} spec.key The metadata key * @param {String} spec.key The metadata key
* @param {String} spec.value The value of the metadata to compare * @param {String} spec.value The value of the metadata to compare
* @param {String} [spec.wildcard_character="%"] The wildcard character
*/ */
var ComplexQuery = newClass(Query, function (spec) { var ComplexQuery = newClass(Query, function (spec) {
......
...@@ -9,17 +9,9 @@ ...@@ -9,17 +9,9 @@
* @class Query * @class Query
* @constructor * @constructor
*/ */
var Query = newClass(function (spec) { var Query = newClass(function () {
/** var that = this, emptyFunction = function () {};
* The wildcard character used to extend comparison action
*
* @attribute wildcard_character
* @type String
* @default "%"
* @optional
*/
this.wildcard_character = spec.wildcard_character || "%";
/** /**
* Filter the item list with matching item only * Filter the item list with matching item only
...@@ -34,10 +26,10 @@ var Query = newClass(function (spec) { ...@@ -34,10 +26,10 @@ var Query = newClass(function (spec) {
* @param {Array} [option.limit] Couple of integer, first is an index and * @param {Array} [option.limit] Couple of integer, first is an index and
* second is the length. * second is the length.
*/ */
this.exec = function (item_list, option) { that.exec = function (item_list, option) {
var i = 0; var i = 0;
while (i < item_list.length) { while (i < item_list.length) {
if (!this.match(item_list[i], option.wildcard_character)) { if (!that.match(item_list[i], option.wildcard_character)) {
item_list.splice(i, 1); item_list.splice(i, 1);
} else { } else {
i += 1; i += 1;
...@@ -62,7 +54,7 @@ var Query = newClass(function (spec) { ...@@ -62,7 +54,7 @@ var Query = newClass(function (spec) {
* @param {Object} item The object to test * @param {Object} item The object to test
* @return {Boolean} true if match, false otherwise * @return {Boolean} true if match, false otherwise
*/ */
this.match = function (item, wildcard_character) { that.match = function (item, wildcard_character) {
return true; return true;
}; };
...@@ -73,7 +65,7 @@ var Query = newClass(function (spec) { ...@@ -73,7 +65,7 @@ var Query = newClass(function (spec) {
* @method toString * @method toString
* @return {String} The string version of this query * @return {String} The string version of this query
*/ */
this.toString = function () { that.toString = function () {
return ""; return "";
}; };
...@@ -84,7 +76,7 @@ var Query = newClass(function (spec) { ...@@ -84,7 +76,7 @@ var Query = newClass(function (spec) {
* @method serialized * @method serialized
* @return {Object} The jsonable object * @return {Object} The jsonable object
*/ */
this.serialized = function () { that.serialized = function () {
return undefined; return undefined;
}; };
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* @param {String} [spec.operator="="] The compare method to use * @param {String} [spec.operator="="] The compare method to use
* @param {String} spec.key The metadata key * @param {String} spec.key The metadata key
* @param {String} spec.value The value of the metadata to compare * @param {String} spec.value The value of the metadata to compare
* @param {String} [spec.wildcard_character="%"] The wildcard character
*/ */
var SimpleQuery = newClass(Query, function (spec) { var SimpleQuery = newClass(Query, function (spec) {
/** /**
...@@ -80,7 +79,7 @@ var SimpleQuery = newClass(Query, function (spec) { ...@@ -80,7 +79,7 @@ var SimpleQuery = newClass(Query, function (spec) {
wildcard_character) { wildcard_character) {
return convertSearchTextToRegExp( return convertSearchTextToRegExp(
comparison_value.toString(), comparison_value.toString(),
wildcard_character || this.wildcard_character wildcard_character || "%"
).test(object_value.toString()); ).test(object_value.toString());
}; };
...@@ -97,7 +96,7 @@ var SimpleQuery = newClass(Query, function (spec) { ...@@ -97,7 +96,7 @@ var SimpleQuery = newClass(Query, function (spec) {
wildcard_character) { wildcard_character) {
return !convertSearchTextToRegExp( return !convertSearchTextToRegExp(
comparison_value.toString(), comparison_value.toString(),
wildcard_character || this.wildcard_character wildcard_character || "%"
).test(object_value.toString()); ).test(object_value.toString());
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment