mongoid_text_search 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module TextSearch
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -22,9 +22,14 @@ module Mongoid
22
22
 
23
23
  # Create a method for searching based on keywords of all specified field.
24
24
  singleton = class << self; self end
25
- singleton.send :define_method, "with_keywords" do |keywords|
25
+ singleton.send :define_method, "with_keywords" do |keywords, *options|
26
+ options = options.first || {}
26
27
  if !keywords.nil? && keywords.count > 0
27
- where(:keywords.all => keywords.collect!{ |keyword| /.*#{keyword}.*/ })
28
+ if options[:match].to_s == "all" || options.empty?
29
+ where(:keywords.all => keywords.collect!{ |keyword| /.*#{keyword}.*/i })
30
+ elsif options[:match].to_s == "any"
31
+ where(:keywords.any => keywords.collect!{ |keyword| /.*#{keyword}.*/i })
32
+ end
28
33
  else
29
34
  where() # Select everything.
30
35
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mongoid_text_search
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Steve Randy Tantra
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-26 00:00:00 +08:00
13
+ date: 2011-03-29 00:00:00 +08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency