algoliasearch-rails 1.20.4 → 1.20.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 51327702006b16333b88bce137fd854e8ffbba7f
4
- data.tar.gz: 97c79f69aeb332096cf93ca367a109c216e3fe74
2
+ SHA256:
3
+ metadata.gz: 38fe24b0c83678a9d4c08faf6faac62a894970be01fa7739b33ef8da116588ed
4
+ data.tar.gz: 8d01bb4274a36b989f9c021245e9aa2f6495ed07fd1bc05351aca9eb7f4953c1
5
5
  SHA512:
6
- metadata.gz: 4623121eec3c0de995007f827971c897ebf35b73aaa911124e4d0cc62a3197bef0d70ca8e262606ac58985baffb7484fb7ea4b2c98a684b6cc4273ce2b74d146
7
- data.tar.gz: a0559d93bd9aadd3fd24c368e6c8949e50d6ccd92d0a1287e9bf8b5f5e484c4e8031432242d09bcc03f87a5d80c5a1e86b0e8eeebb2ba2305a116a4826b6407b
6
+ metadata.gz: ac5bbe58eb801e574af5c7a7155bfed178928ffec9065a2845aa6d9189eaca677f103891c3e61a2be38cd7766e1685c32fba9050ea20f2b7fb103923e755ce1a
7
+ data.tar.gz: 2a235e08fc3d7d8620dac3048df6b6e9936b00ce27858f3020296dd98c44ff892f76ea255476be2c6cb835ef6458011d6d21d89fcc0d1ab89e37e214c32681bd
@@ -10,22 +10,30 @@ matrix:
10
10
  env: RAILS_VERSION=3.2.0
11
11
  - rvm: 1.9.3
12
12
  env: RAILS_VERSION=4.2
13
- - rvm: 2.2.5
13
+ - rvm: 2.2.9
14
14
  env: RAILS_VERSION=3.2.0
15
- - rvm: 2.2.5
15
+ - rvm: 2.2.9
16
16
  env: RAILS_VERSION=4.2
17
- - rvm: 2.2.5
17
+ - rvm: 2.2.9
18
18
  env: RAILS_VERSION=5.1
19
- - rvm: 2.3.4
19
+ - rvm: 2.3.6
20
20
  env: RAILS_VERSION=3.2.0
21
- - rvm: 2.3.4
21
+ - rvm: 2.3.6
22
22
  env: RAILS_VERSION=4.2
23
- - rvm: 2.3.4
23
+ - rvm: 2.3.6
24
24
  env: RAILS_VERSION=5.1
25
- - rvm: 2.4.1
25
+ - rvm: 2.4.3
26
26
  env: RAILS_VERSION=4.2
27
- - rvm: 2.4.1
28
- env: RAILS_VERSION=5.1
27
+ - rvm: 2.4.3
28
+ env: RAILS_VERSION=5.1 SEQUEL_VERSION=4.0
29
+ - rvm: 2.4.3
30
+ env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
31
+ - rvm: 2.5.0
32
+ env: RAILS_VERSION=4.2
33
+ - rvm: 2.5.0
34
+ env: RAILS_VERSION=5.1 SEQUEL_VERSION=4.0
35
+ - rvm: 2.5.0
36
+ env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
29
37
  # - rvm: jruby-9.1.2.0
30
38
  # env: RAILS_VERSION=3.2.0
31
39
  # - rvm: jruby-9.1.2.0
@@ -45,11 +53,9 @@ matrix:
45
53
  allow_failures:
46
54
  - rvm: rbx-2
47
55
  before_install:
56
+ - wget http://api-key-dealer.herokuapp.com/clients/algolia-keys && chmod +x algolia-keys
48
57
  - gem install bundler
49
58
  - bundle --version
50
- install: rm -f Gemfile.lock && bundle install
59
+ install: rm -f Gemfile.lock && bundle install --without development
51
60
  cache: bundler
52
- env:
53
- global:
54
- - secure: "o/Hi/6KnBugN5P/cpVtpwyKrK5fVzAc0efw+qZ9ZqwqZN0GmipZrHmRNuLVUxVf+CIcqfLpIT0U172XGOZ5zJ1gs3qZZrDsJ1ptXnPyvvCrw+VX5yGhMh67JnlO0WLWvci0WdltJTmrhCoLSSw39nCPswC7I6/hai4KyiOXoMk4="
55
- - secure: "Jv9jOYRwJq5i17Int/p75330yxCJXKLYlstHuBjwkKa6anJHFSXQaAxWj8sZHCY4IAVDsBfdi0j6S3dtVu2LaVLA3hfPp36YRVolSZu9zLbGqyPKBWM7E3i7GkS3Jub0nMV3Yo3cMeiFzQ4BmpSQOYo0biCkL8bh4/5NRZ7Q6VI="
61
+ script: eval $(./algolia-keys export) && bundle exec rake
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
1
  CHANGELOG
2
2
 
3
+ 2018-12-07 1.20.6
4
+
5
+ * Better support for Rails 5.1 and deprecated `attribute_changed?`
6
+ * Better support for `after_commit` for Sequel 5.0
7
+
3
8
  2017-12-04 1.20.4
4
9
 
5
10
  * Remove Bundler and RubyGems requirements
data/Gemfile CHANGED
@@ -39,7 +39,9 @@ group :test do
39
39
  gem 'activerecord-jdbc-adapter', :platform => :jruby
40
40
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
41
41
  gem 'redgreen'
42
- gem 'sequel'
42
+
43
+ sequel_version = ENV['SEQUEL_VERSION'] ? "~> #{ENV['SEQUEL_VERSION']}" : '>= 4.0'
44
+ gem 'sequel', sequel_version
43
45
  end
44
46
 
45
47
  group :development do
@@ -39,23 +39,23 @@ GEM
39
39
  minitest (~> 5.1)
40
40
  tzinfo (~> 1.1)
41
41
  addressable (2.4.0)
42
- algoliasearch (1.17.0)
43
- httpclient (~> 2.8.3)
42
+ algoliasearch (1.23.2)
43
+ httpclient (~> 2.8, >= 2.8.3)
44
44
  json (>= 1.5.1)
45
45
  arel (7.1.4)
46
- backports (3.6.8)
46
+ backports (3.11.1)
47
47
  builder (3.2.3)
48
48
  concurrent-ruby (1.0.5)
49
49
  diff-lcs (1.3)
50
50
  erubis (2.7.0)
51
- ethon (0.10.1)
51
+ ethon (0.11.0)
52
52
  ffi (>= 1.3.0)
53
- faraday (0.11.0)
53
+ faraday (0.15.2)
54
54
  multipart-post (>= 1.2, < 3)
55
- faraday_middleware (0.11.0.1)
55
+ faraday_middleware (0.12.2)
56
56
  faraday (>= 0.7.4, < 1.0)
57
- ffi (1.9.18)
58
- gh (0.15.0)
57
+ ffi (1.9.25)
58
+ gh (0.15.1)
59
59
  addressable (~> 2.4.0)
60
60
  backports
61
61
  faraday (~> 0.8)
@@ -64,9 +64,10 @@ GEM
64
64
  net-http-pipeline
65
65
  globalid (0.3.7)
66
66
  activesupport (>= 4.1.0)
67
- highline (1.7.8)
67
+ highline (1.7.10)
68
68
  httpclient (2.8.3)
69
- i18n (0.8.1)
69
+ i18n (0.9.5)
70
+ concurrent-ruby (~> 1.0)
70
71
  json (1.8.6)
71
72
  kaminari (1.0.1)
72
73
  activesupport (>= 4.1.0)
@@ -86,23 +87,23 @@ GEM
86
87
  nokogiri (>= 1.5.9)
87
88
  mail (2.6.4)
88
89
  mime-types (>= 1.16, < 4)
89
- method_source (0.8.2)
90
+ method_source (0.9.0)
90
91
  mime-types (3.1)
91
92
  mime-types-data (~> 3.2015)
92
93
  mime-types-data (3.2016.0521)
93
- mini_portile2 (2.1.0)
94
- minitest (5.10.1)
95
- multi_json (1.12.1)
94
+ mini_portile2 (2.3.0)
95
+ minitest (5.11.3)
96
+ multi_json (1.13.1)
96
97
  multipart-post (2.0.0)
97
98
  net-http-persistent (2.9.4)
98
99
  net-http-pipeline (1.0.1)
99
100
  nio4r (2.0.0)
100
- nokogiri (1.7.0.1)
101
- mini_portile2 (~> 2.1.0)
101
+ nokogiri (1.8.4)
102
+ mini_portile2 (~> 2.3.0)
102
103
  pusher-client (0.6.2)
103
104
  json
104
105
  websocket (~> 1.0)
105
- rack (2.0.1)
106
+ rack (2.0.3)
106
107
  rack-test (0.6.3)
107
108
  rack (>= 1.0)
108
109
  rails (5.0.2)
@@ -129,7 +130,7 @@ GEM
129
130
  rake (>= 0.8.7)
130
131
  thor (>= 0.18.1, < 2.0)
131
132
  rake (10.1.1)
132
- rdoc (5.1.0)
133
+ rdoc (6.0.4)
133
134
  redgreen (1.2.2)
134
135
  rspec (2.99.0)
135
136
  rspec-core (~> 2.99.0)
@@ -139,7 +140,7 @@ GEM
139
140
  rspec-expectations (2.99.2)
140
141
  diff-lcs (>= 1.1.3, < 2.0)
141
142
  rspec-mocks (2.99.4)
142
- sequel (4.44.0)
143
+ sequel (4.49.0)
143
144
  sprockets (3.7.1)
144
145
  concurrent-ruby (~> 1.0)
145
146
  rack (> 1, < 3)
@@ -148,7 +149,7 @@ GEM
148
149
  activesupport (>= 4.0)
149
150
  sprockets (>= 3.0.0)
150
151
  sqlite3 (1.3.13)
151
- thor (0.19.4)
152
+ thor (0.20.0)
152
153
  thread_safe (0.3.6)
153
154
  travis (1.8.8)
154
155
  backports
@@ -161,9 +162,9 @@ GEM
161
162
  typhoeus (~> 0.6, >= 0.6.8)
162
163
  typhoeus (0.8.0)
163
164
  ethon (>= 0.8.0)
164
- tzinfo (1.2.2)
165
+ tzinfo (1.2.5)
165
166
  thread_safe (~> 0.1)
166
- websocket (1.2.4)
167
+ websocket (1.2.5)
167
168
  websocket-driver (0.6.5)
168
169
  websocket-extensions (>= 0.1.0)
169
170
  websocket-extensions (0.1.2)
@@ -184,10 +185,10 @@ DEPENDENCIES
184
185
  rdoc
185
186
  redgreen
186
187
  rspec (>= 2.5.0, < 3.0)
187
- sequel
188
+ sequel (>= 4.0)
188
189
  sqlite3
189
190
  travis
190
191
  will_paginate (>= 2.3.15)
191
192
 
192
193
  BUNDLED WITH
193
- 1.16.0
194
+ 1.16.6
data/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2013 Algolia
4
- http://www.algolia.com/
3
+ Copyright (c) 2013-Present Algolia
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
@@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
9
  copies of the Software, and to permit persons to whom the Software is
11
10
  furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
15
14
 
16
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
+
1
2
  # Algolia Search API Client for Rails
2
3
 
3
- [Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
4
+ [Algolia Search](https://www.algolia.com) is a hosted full-text, numerical,
5
+ and faceted search engine capable of delivering realtime results from the first keystroke.
4
6
 
5
7
  [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.svg)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.svg)](https://codeclimate.com/github/algolia/algoliasearch-rails) ![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square) ![Mongoid](https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square) ![Sequel](https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square)
6
8
 
@@ -8,8 +10,7 @@
8
10
  This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem.
9
11
  Rails 3.x, 4.x and 5.x are all supported.
10
12
 
11
- You might be interested in the sample Ruby on Rails application providing a `autocomplete.js`-based auto-completion and `instantsearch.js`-based instant search results page: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
12
-
13
+ You might be interested in the sample Ruby on Rails application providing a `autocomplete.js`-based auto-completion and `InstantSearch.js`-based instant search results page: [algoliasearch-rails-example](https://github.com/algolia/algoliasearch-rails-example/).
13
14
 
14
15
 
15
16
 
@@ -18,19 +19,14 @@ You might be interested in the sample Ruby on Rails application providing a `aut
18
19
  You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/rails/).
19
20
 
20
21
 
21
- ## Table of Contents
22
-
23
-
24
22
 
25
23
  1. **[Setup](#setup)**
26
-
27
24
  * [Install](#install)
28
25
  * [Configuration](#configuration)
29
26
  * [Timeouts](#timeouts)
30
27
  * [Notes](#notes)
31
28
 
32
29
  1. **[Usage](#usage)**
33
-
34
30
  * [Index Schema](#index-schema)
35
31
  * [Relevancy](#relevancy)
36
32
  * [Indexing](#indexing)
@@ -44,13 +40,12 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
44
40
  * [Geo-Search](#geo-search)
45
41
 
46
42
  1. **[Options](#options)**
47
-
48
43
  * [Auto-indexing &amp; asynchronism](#auto-indexing--asynchronism)
49
44
  * [Custom index name](#custom-index-name)
50
45
  * [Per-environment indices](#per-environment-indices)
51
46
  * [Custom attribute definition](#custom-attribute-definition)
52
47
  * [Nested objects/relations](#nested-objectsrelations)
53
- * [Custom `objectID`](#custom-objectid)
48
+ * [Custom <code>objectID</code>](#custom-codeobjectidcode)
54
49
  * [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
55
50
  * [Sanitizer](#sanitizer)
56
51
  * [UTF-8 Encoding](#utf-8-encoding)
@@ -58,7 +53,6 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
58
53
  * [Configuration example](#configuration-example)
59
54
 
60
55
  1. **[Indices](#indices)**
61
-
62
56
  * [Manual indexing](#manual-indexing)
63
57
  * [Manual removal](#manual-removal)
64
58
  * [Reindexing](#reindexing)
@@ -69,15 +63,12 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
69
63
  * [Target multiple indices](#target-multiple-indices)
70
64
 
71
65
  1. **[Testing](#testing)**
72
-
73
66
  * [Notes](#notes)
74
67
 
75
68
 
76
69
 
77
70
 
78
71
 
79
-
80
-
81
72
  # Setup
82
73
 
83
74
 
@@ -140,6 +131,7 @@ Contact.algolia_search("jon doe") # <=> Contact.search("jon doe")
140
131
 
141
132
 
142
133
 
134
+
143
135
  # Usage
144
136
 
145
137
 
@@ -448,13 +440,14 @@ At query time, specify <code>{ aroundLatLng: "37.33, -121.89", aroundRadius: 500
448
440
 
449
441
 
450
442
 
443
+
451
444
  # Options
452
445
 
453
446
 
454
447
 
455
448
  ## Auto-indexing & asynchronism
456
449
 
457
- Each time a record is saved; it will be - asynchronously - indexed. On the other hand, each time a record is destroyed, it will be - asynchronously - removed from the index. That means that a network call with the ADD/DELETE operation is sent **synchronously** to the Algolia API but then the engine will **asynchronously** process the operation (so if you do a search just after, the results may not reflect it yet).
450
+ Each time a record is saved, it will be *asynchronously* indexed. On the other hand, each time a record is destroyed, it will be - asynchronously - removed from the index. That means that a network call with the ADD/DELETE operation is sent **synchronously** to the Algolia API but then the engine will **asynchronously** process the operation (so if you do a search just after, the results may not reflect it yet).
458
451
 
459
452
  You can disable auto-indexing and auto-removing setting the following options:
460
453
 
@@ -659,6 +652,8 @@ end
659
652
 
660
653
  ## Nested objects/relations
661
654
 
655
+ ### Defining the relationship
656
+
662
657
  You can easily embed nested objects defining an extra attribute returning any JSON-compliant object (an array or a hash or a combination of both).
663
658
 
664
659
  ```ruby
@@ -684,6 +679,82 @@ class Profile < ActiveRecord::Base
684
679
  end
685
680
  ```
686
681
 
682
+ ### Propagating the change from a nested child
683
+
684
+ #### With ActiveRecord
685
+
686
+ With ActiveRecord, we'll be using `touch` and `after_touch` to achieve this.
687
+
688
+ ```ruby
689
+ # app/models/app.rb
690
+ class App < ApplicationRecord
691
+ include AlgoliaSearch
692
+
693
+ belongs_to :author, class_name: :User
694
+ after_touch :index!
695
+
696
+ algoliasearch do
697
+ attribute :title
698
+ attribute :author do
699
+ author.as_json
700
+ end
701
+ end
702
+ end
703
+
704
+ # app/models/user.rb
705
+ class User < ApplicationRecord
706
+ # If your association uses belongs_to
707
+ # - use `touch: true`
708
+ # - do not define an `after_save` hook
709
+ has_many :apps, foreign_key: :author_id
710
+
711
+ after_save { apps.each(&:touch) }
712
+ end
713
+ ```
714
+
715
+ #### With Sequel
716
+
717
+ With Sequel, you can use the `touch` plugin to propagate the changes:
718
+
719
+ ```ruby
720
+ # app/models/app.rb
721
+ class App < Sequel::Model
722
+ include AlgoliaSearch
723
+
724
+ many_to_one :author, class: :User
725
+
726
+ plugin :timestamps
727
+ plugin :touch
728
+
729
+ algoliasearch do
730
+ attribute :title
731
+ attribute :author do
732
+ author.to_hash
733
+ end
734
+ end
735
+ end
736
+
737
+ # app/models/user.rb
738
+ class User < Sequel::Model
739
+ one_to_many :apps, key: :author_id
740
+
741
+ plugin :timestamps
742
+ # Can't use the associations since it won't trigger the after_save
743
+ plugin :touch
744
+
745
+ # Define the associations that need to be touched here
746
+ # Less performant, but allows for the after_save hook to trigger
747
+ def touch_associations
748
+ apps.map(&:touch)
749
+ end
750
+
751
+ def touch
752
+ super
753
+ touch_associations
754
+ end
755
+ end
756
+ ```
757
+
687
758
  ## Custom `objectID`
688
759
 
689
760
  By default, the `objectID` is based on your record's `id`. You can change this behavior specifying the `:id` option (be sure to use a uniq field).
@@ -864,6 +935,7 @@ end
864
935
 
865
936
 
866
937
 
938
+
867
939
  # Indices
868
940
 
869
941
 
@@ -1046,6 +1118,7 @@ Book.search 'foo bar', index: 'Book_by_editor'
1046
1118
 
1047
1119
 
1048
1120
 
1121
+
1049
1122
  # Testing
1050
1123
 
1051
1124
 
@@ -1096,3 +1169,4 @@ end
1096
1169
  ```
1097
1170
 
1098
1171
 
1172
+
@@ -2,6 +2,8 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'lib', 'algoliasearch', 'version')
4
4
 
5
+ require 'date'
6
+
5
7
  Gem::Specification.new do |s|
6
8
  s.name = "algoliasearch-rails"
7
9
  s.version = AlgoliaSearch::VERSION
@@ -59,7 +59,7 @@ module AlgoliaSearch
59
59
  :unretrievableAttributes, :disableTypoToleranceOnWords, :disableTypoToleranceOnAttributes, :altCorrections,
60
60
  :ignorePlurals, :maxValuesPerFacet, :distinct, :numericAttributesToIndex, :numericAttributesForFiltering,
61
61
  :allowTyposOnNumericTokens, :allowCompressionOfIntegerArray,
62
- :advancedSyntax, :disablePrefixOnAttributes, :disableTypoToleranceOnAttributes,
62
+ :advancedSyntax, :disablePrefixOnAttributes,
63
63
  :paginationLimitedTo]
64
64
  OPTIONS.each do |k|
65
65
  define_method k do |v|
@@ -402,7 +402,6 @@ module AlgoliaSearch
402
402
  class_eval do
403
403
  copy_after_validation = instance_method(:after_validation)
404
404
  copy_before_save = instance_method(:before_save)
405
- copy_after_commit = instance_method(:after_commit)
406
405
 
407
406
  define_method(:after_validation) do |*args|
408
407
  super(*args)
@@ -416,10 +415,23 @@ module AlgoliaSearch
416
415
  super(*args)
417
416
  end
418
417
 
419
- define_method(:after_commit) do |*args|
420
- super(*args)
421
- copy_after_commit.bind(self).call
422
- algolia_perform_index_tasks
418
+ sequel_version = Gem::Version.new(Sequel.version)
419
+ if sequel_version >= Gem::Version.new('4.0.0') && sequel_version < Gem::Version.new('5.0.0')
420
+ copy_after_commit = instance_method(:after_commit)
421
+ define_method(:after_commit) do |*args|
422
+ super(*args)
423
+ copy_after_commit.bind(self).call
424
+ algolia_perform_index_tasks
425
+ end
426
+ else
427
+ copy_after_save = instance_method(:after_save)
428
+ define_method(:after_save) do |*args|
429
+ super(*args)
430
+ copy_after_save.bind(self).call
431
+ self.db.after_commit do
432
+ algolia_perform_index_tasks
433
+ end
434
+ end
423
435
  end
424
436
  end
425
437
  else
@@ -703,14 +715,14 @@ module AlgoliaSearch
703
715
  next if options[:slave] || options[:replica]
704
716
  return true if algolia_object_id_changed?(object, options)
705
717
  settings.get_attribute_names(object).each do |k|
706
- changed_method = "#{k}_changed?"
718
+ changed_method = attribute_changed_method(k)
707
719
  return true if !object.respond_to?(changed_method) || object.send(changed_method)
708
720
  end
709
721
  [options[:if], options[:unless]].each do |condition|
710
722
  case condition
711
723
  when nil
712
724
  when String, Symbol
713
- changed_method = "#{condition}_changed?"
725
+ changed_method = attribute_changed_method(condition)
714
726
  return true if !object.respond_to?(changed_method) || object.send(changed_method)
715
727
  else
716
728
  # if the :if, :unless condition is a anything else,
@@ -785,7 +797,7 @@ module AlgoliaSearch
785
797
  end
786
798
 
787
799
  def algolia_object_id_changed?(o, options = nil)
788
- m = "#{algolia_object_id_method(options)}_changed?"
800
+ m = attribute_changed_method(algolia_object_id_method(options))
789
801
  o.respond_to?(m) ? o.send(m) : false
790
802
  end
791
803
 
@@ -879,6 +891,15 @@ module AlgoliaSearch
879
891
  yield items unless items.empty?
880
892
  end
881
893
  end
894
+
895
+ def attribute_changed_method(attr)
896
+ if defined?(::ActiveRecord) && ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 1 ||
897
+ (defined?(::ActiveRecord) && ActiveRecord::VERSION::MAJOR > 5)
898
+ "will_save_change_to_#{attr}?"
899
+ else
900
+ "#{attr}_changed?"
901
+ end
902
+ end
882
903
  end
883
904
 
884
905
  # these are the instance methods included
@@ -1,3 +1,3 @@
1
1
  module AlgoliaSearch
2
- VERSION = '1.20.4'
2
+ VERSION = '1.20.6'
3
3
  end
@@ -31,6 +31,6 @@ end
31
31
  # avoid concurrent access to the same index
32
32
  def safe_index_name(name)
33
33
  return name if ENV['TRAVIS'].to_s != "true"
34
- id = ENV['TRAVIS_JOB_NUMBER'].split('.').last
35
- "#{name}_travis-#{id}"
34
+ id = ENV['TRAVIS_JOB_NUMBER']
35
+ "TRAVIS_RAILS_#{name}_#{id}"
36
36
  end
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.20.4
4
+ version: 1.20.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2018-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.6.13
192
+ rubygems_version: 2.7.7
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: AlgoliaSearch integration to your favorite ORM