mongoid-sphinx 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,15 +13,15 @@ module MongoidSphinx
13
13
  end
14
14
 
15
15
  private
16
-
16
+
17
17
  # Parse the config/sphinx.yml file - if it exists
18
18
  #
19
19
  def parse_config
20
20
  path = "#{Rails.root}/config/sphinx.yml"
21
21
  return unless File.exists?(path)
22
-
22
+
23
23
  conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]
24
-
24
+
25
25
  conf.each do |key,value|
26
26
  self.send("#{key}=", value) if self.respond_to?("#{key}=")
27
27
  end
@@ -5,7 +5,7 @@ module Mongoid
5
5
  module Sphinx
6
6
  extend ActiveSupport::Concern
7
7
  included do
8
- cattr_accessor :search_fields
8
+ cattr_accessor :search_fields
9
9
  end
10
10
 
11
11
  module ClassMethods
@@ -16,7 +16,7 @@ module Mongoid
16
16
  def search(query, options = {})
17
17
  client = MongoidSphinx::Configuration.instance.client
18
18
 
19
- query = query + " @classname #{@document.class.to_s}"
19
+ query = query + " @classname #{self.to_s}"
20
20
 
21
21
  client.match_mode = options[:match_mode] || :extended
22
22
  client.limit = options[:limit] if options.key?(:limit)
@@ -29,15 +29,14 @@ module Mongoid
29
29
 
30
30
  result = client.query(query)
31
31
 
32
- #TODO
33
32
  if result and result[:status] == 0 and (matches = result[:matches])
34
33
  classname = nil
35
34
  ids = matches.collect do |row|
36
35
  classname = MongoidSphinx::MultiAttribute.decode(row[:attributes]['csphinx-class'])
37
- row[:doc].to_s rescue nil
36
+ (100000000000000000000000 + row[:doc]).to_s rescue nil
38
37
  end.compact
39
38
 
40
- return ids if options[:raw]
39
+ return ids if options[:raw] or ids.empty?
41
40
  return Object.const_get(classname).find(ids)
42
41
  else
43
42
  return []
@@ -1,3 +1,3 @@
1
1
  module MongoidSphinx #:nodoc
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Hodgson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-22 00:00:00 -05:00
18
+ date: 2011-01-04 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency