algoliasearch-rails 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +2 -2
- data/lib/algoliasearch-rails.rb +11 -4
- data/spec/utilities_spec.rb +1 -1
- 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: be6d06df4e6fd61f5f9daaf332cac49de42870a6
|
4
|
+
data.tar.gz: de4d74b403c0e516906c246675bd3fa0f0b9addc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d945380296434a3f38af3ec53742b0939f08dd599e2392f75e3615f1a3fc801c48b57a2715170df8139b48d0b36ad1f975d34f3686b779804ddcdc4538d2405
|
7
|
+
data.tar.gz: 6909f7711b56635e99c8ebe3c260a957c36c4c68126acd9a317c0edb07cae0c3c3ff779b733e8a9dc4cad469bcdc17d20eac8e98b78c3f6107257e7df41f28e5
|
data/ChangeLog
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2013-12-05 1.5.2
|
4
|
+
|
5
|
+
* object's attributes must be fetched unscoped to ensure associations will not be impacted by the conditions
|
6
|
+
* you can now use `Model.index` to access the underlying index object
|
7
|
+
|
3
8
|
2013-12-03 1.5.1
|
4
9
|
|
5
10
|
* ability to specify which attribute is used as objectID
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.2
|
data/algoliasearch-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "algoliasearch-rails"
|
8
|
-
s.version = "1.5.
|
8
|
+
s.version = "1.5.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Algolia"]
|
12
|
-
s.date = "2013-12-
|
12
|
+
s.date = "2013-12-05"
|
13
13
|
s.description = "AlgoliaSearch integration to your favorite ORM"
|
14
14
|
s.email = "contact@algolia.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -69,8 +69,10 @@ module AlgoliaSearch
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def get_attributes(object)
|
72
|
-
|
73
|
-
|
72
|
+
object.class.unscoped do
|
73
|
+
return object.attributes if @attributes.nil? or @attributes.length == 0
|
74
|
+
Hash[@attributes.map { |name, value| [name.to_s, value.call(object) ] }]
|
75
|
+
end
|
74
76
|
end
|
75
77
|
|
76
78
|
def get_setting(name)
|
@@ -93,7 +95,7 @@ module AlgoliaSearch
|
|
93
95
|
def algoliasearch(options = {}, &block)
|
94
96
|
@index_settings = IndexSettings.new(block_given? ? Proc.new : nil)
|
95
97
|
@settings = @index_settings.to_settings
|
96
|
-
@options = { type: model_name, per_page: @index_settings.get_setting(:hitsPerPage) || 10, page: 1 }.merge(options)
|
98
|
+
@options = { type: full_const_get(model_name.to_s), per_page: @index_settings.get_setting(:hitsPerPage) || 10, page: 1 }.merge(options)
|
97
99
|
|
98
100
|
attr_accessor :highlight_result
|
99
101
|
|
@@ -160,7 +162,7 @@ module AlgoliaSearch
|
|
160
162
|
ensure_init
|
161
163
|
json = @index.search(q, Hash[settings.map { |k,v| [k.to_s, v.to_s] }])
|
162
164
|
results = json['hits'].map do |hit|
|
163
|
-
o =
|
165
|
+
o = @options[:type].where(object_id_method => hit['objectID']).first
|
164
166
|
o.highlight_result = hit['_highlightResult']
|
165
167
|
o
|
166
168
|
end
|
@@ -174,6 +176,11 @@ module AlgoliaSearch
|
|
174
176
|
@index.set_settings(@settings) if index_settings_changed?(current_settings, @settings)
|
175
177
|
end
|
176
178
|
|
179
|
+
def index
|
180
|
+
ensure_init
|
181
|
+
@index
|
182
|
+
end
|
183
|
+
|
177
184
|
def must_reindex?(object)
|
178
185
|
return true if object_id_changed?(object)
|
179
186
|
@index_settings.get_attributes(object).each do |k, v|
|
data/spec/utilities_spec.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|