algoliasearch-rails 1.5.1 → 1.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f261644d4f85253064f4683e6815c3fc4ef8a36
4
- data.tar.gz: 47b1f0cfccd530d7fd5987fa82019abc4363e4da
3
+ metadata.gz: be6d06df4e6fd61f5f9daaf332cac49de42870a6
4
+ data.tar.gz: de4d74b403c0e516906c246675bd3fa0f0b9addc
5
5
  SHA512:
6
- metadata.gz: f596456245ab08f64f23f7fb908d839489fb1bedfcf2b36752a67d7c561f52ab974e87a40c3a57614334b0ae56345d8e24779b54f3b561e639f7f741d767ed5f
7
- data.tar.gz: 77cd27fb4231f8e6c4fc7076993557d23f17f89edec86aa299c03fe2807c37fce722b4aac9317446079cfa597a535e6dc1d081bdfa984125172eff8c997f888b
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
+ 1.5.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "algoliasearch-rails"
8
- s.version = "1.5.1"
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-03"
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 = [
@@ -69,8 +69,10 @@ module AlgoliaSearch
69
69
  end
70
70
 
71
71
  def get_attributes(object)
72
- return object.attributes if @attributes.nil? or @attributes.length == 0
73
- Hash[@attributes.map { |name, value| [name.to_s, value.call(object) ] }]
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 = full_const_get(@options[:type].to_s).where(object_id_method => hit['objectID']).first
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|
@@ -10,7 +10,7 @@ describe AlgoliaSearch::Utilities do
10
10
  include AlgoliaSearch
11
11
 
12
12
  def self.model_name
13
- "dummy"
13
+ "Dummy"
14
14
  end
15
15
 
16
16
  algoliasearch
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.1
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-03 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json