summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Gleeson <matt@gleeson.org>2013-09-28 08:24:40 -0700
committerMatt Gleeson <matt@gleeson.org>2013-09-28 08:24:40 -0700
commit57f02150013c08bd121c51999ac2bbfb468e9f7b (patch)
tree8e5714e582265822fd4fdc19fd72fe60da59d2d9
parentbfd53dde9524f203c3495efe048005d94b8a065f (diff)
downloadchef-zero-57f02150013c08bd121c51999ac2bbfb468e9f7b.tar.gz
handle a list of values properly. add matches_doc?
-rw-r--r--lib/chef_zero/solr/query/range_query.rb33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/chef_zero/solr/query/range_query.rb b/lib/chef_zero/solr/query/range_query.rb
index afa3fa2..5428a6f 100644
--- a/lib/chef_zero/solr/query/range_query.rb
+++ b/lib/chef_zero/solr/query/range_query.rb
@@ -14,21 +14,28 @@ module ChefZero
end
def matches_values?(values)
- value = values.first
- case @from <=> value
- when -1
- return false
- when 0
- return false if !@from_inclusive
+ values.any? do |value|
+ case @from <=> value
+ when -1
+ return false
+ when 0
+ return false if !@from_inclusive
+ end
+ case value <=> @to
+ when 1
+ return false
+ when 0
+ return false if !@to_inclusive
+ end
+ return true
end
- case value <=> @to
- when 1
- return false
- when 0
- return false if !@to_inclusive
- end
- return true
end
+
+ def matches_doc?(doc)
+ matches_values?(doc[DEFAULT_FIELD])
+ end
+
+ DEFAULT_FIELD = "text"
end
end
end