algoliasearch-rails 1.10.6 → 1.10.7
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.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +2 -2
- data/lib/algoliasearch-rails.rb +15 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80b4afee8f3b76e7ae6bc4a85e36f7a2ac11404d
|
4
|
+
data.tar.gz: 293b6baee5f060f5524ae2f573c9bccdb044e4fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a471bf1df7cf7d5c4a2645b8aaeff63baaf7e7e2dc970e33e07a7e23fe6d5cfc48d0e773c06ca730ff5bc55b4263449ef25018e9128a0e01dacdd67485d3c27e
|
7
|
+
data.tar.gz: e6c60c16d668d91e7960ee79532d20567e6d29d9fdf1c51948f05358eec0759749ee0adc1999eaeb00e35d7e3ad3ec07952eb547c5a0771c3e71f390efd46df3
|
data/ChangeLog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.10.
|
1
|
+
1.10.7
|
data/algoliasearch-rails.gemspec
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "algoliasearch-rails"
|
9
|
-
s.version = "1.10.
|
9
|
+
s.version = "1.10.7"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Algolia"]
|
13
|
-
s.date = "2014-07-
|
13
|
+
s.date = "2014-07-17"
|
14
14
|
s.description = "AlgoliaSearch integration to your favorite ORM"
|
15
15
|
s.email = "contact@algolia.com"
|
16
16
|
s.extra_rdoc_files = [
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -86,11 +86,20 @@ module AlgoliaSearch
|
|
86
86
|
alias :add_attributes :add_attribute
|
87
87
|
|
88
88
|
def get_attributes(object)
|
89
|
-
object.class
|
89
|
+
clazz = object.class
|
90
|
+
if defined?(::Mongoid::Document) && clazz.include?(::Mongoid::Document)
|
91
|
+
# work-around mongoid 2.4's unscoped method, not accepting a block
|
90
92
|
res = @attributes.nil? || @attributes.length == 0 ? object.attributes :
|
91
93
|
Hash[@attributes.map { |name, value| [name.to_s, value.call(object) ] }]
|
92
94
|
@additional_attributes.each { |name, value| res[name.to_s] = value.call(object) } if @additional_attributes
|
93
95
|
res
|
96
|
+
else
|
97
|
+
object.class.unscoped do
|
98
|
+
res = @attributes.nil? || @attributes.length == 0 ? object.attributes :
|
99
|
+
Hash[@attributes.map { |name, value| [name.to_s, value.call(object) ] }]
|
100
|
+
@additional_attributes.each { |name, value| res[name.to_s] = value.call(object) } if @additional_attributes
|
101
|
+
res
|
102
|
+
end
|
94
103
|
end
|
95
104
|
end
|
96
105
|
|
@@ -347,8 +356,12 @@ module AlgoliaSearch
|
|
347
356
|
params[:page] -= 1 if params[:page].to_i > 0
|
348
357
|
end
|
349
358
|
json = algolia_raw_search(q, params)
|
359
|
+
hit_ids = json['hits'].map { |hit| hit['objectID'] }
|
360
|
+
results_by_id = algoliasearch_options[:type].where(algolia_object_id_method => hit_ids).index_by do |hit|
|
361
|
+
algolia_object_id_of(hit)
|
362
|
+
end
|
350
363
|
results = json['hits'].map do |hit|
|
351
|
-
o =
|
364
|
+
o = results_by_id[hit['objectID']]
|
352
365
|
if o
|
353
366
|
o.highlight_result = hit['_highlightResult']
|
354
367
|
o
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|