polymorphic_integer_type 2.3.1 → 3.0.0

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
2
  SHA256:
3
- metadata.gz: 0d7804d64bb9623f7c1e99d9cc3e9d87660c4aa0377dcb990d0f36116e9d0f84
4
- data.tar.gz: 4530a6917ae04b9e5b22823551a2c999909b32406d899aad950ac26373db333a
3
+ metadata.gz: 96fa454bca5e242711a9cc17183c3dbfe7b8c9303bd0bbe1cd246d030761639d
4
+ data.tar.gz: 536c3c02769ef0e020e300225e9e1cf453235d5341adc6f98cd973e1d7ea79d1
5
5
  SHA512:
6
- metadata.gz: 0017c3e990e834177af622495715ea839c720bd5d511faf9675ae74820e9bff2a2cf63c7d648b7098b135b009a88a7f5a8386ee359e412f22749c77980d18939
7
- data.tar.gz: 156289387a5dd038b1c8380b18514e78f9f3c418c0fd0fff5deb844d8a94006ea742fd3cc47ed6948cf970f3e1dde106df0a60b781b388300ed969aa5f6bdb7c
6
+ metadata.gz: dae28edc37bb45b1852a9d1f60347e74496d2ba371645514654ae9807a680de40d5487779b219a0fef3cad4ce220b2f0444e51c9907dbd6269653d2082eff1bf
7
+ data.tar.gz: 32e6df91034dd5423d8c3787512246e570a1cec2d5d85bdfee2eed2d1932640562dc9ef08881aa6fe09edb1d218597613833ac56389f3807327a28cef7e517db
data/README.md CHANGED
@@ -47,8 +47,6 @@ Or install it yourself as:
47
47
 
48
48
  $ gem install polymorphic_integer_type
49
49
 
50
- For Rails 3.2 use version < 2. Version >= 2 has been tested on Rails 4.2 and Ruby 2.1
51
-
52
50
  ## Usage
53
51
 
54
52
  For the model where the `belongs_to` is defined, include `PolymorphicIntegerType::Extensions` and set the `polymorphic:` option to a hash that maps an integer stored in the database to the name of a Ruby class.
@@ -1,5 +1,5 @@
1
1
  GIT
2
- remote: git://github.com/rails/rails.git
2
+ remote: https://github.com/rails/rails.git
3
3
  revision: ac6aa32f7cf66264ba87eabed7c042bb60bcf3a2
4
4
  branch: 5-0-stable
5
5
  specs:
@@ -18,36 +18,44 @@ GIT
18
18
  PATH
19
19
  remote: ..
20
20
  specs:
21
- polymorphic_integer_type (2.2.4)
22
- activerecord
21
+ polymorphic_integer_type (3.0.0)
22
+ activerecord (< 6.1)
23
23
 
24
24
  GEM
25
25
  remote: https://rubygems.org/
26
26
  specs:
27
27
  arel (7.1.4)
28
- byebug (11.0.1)
29
- concurrent-ruby (1.1.5)
30
- diff-lcs (1.3)
31
- i18n (1.7.0)
28
+ byebug (11.1.3)
29
+ coderay (1.1.3)
30
+ concurrent-ruby (1.1.8)
31
+ diff-lcs (1.4.4)
32
+ i18n (1.8.10)
32
33
  concurrent-ruby (~> 1.0)
33
- minitest (5.13.0)
34
- rake (13.0.1)
35
- rspec (3.9.0)
36
- rspec-core (~> 3.9.0)
37
- rspec-expectations (~> 3.9.0)
38
- rspec-mocks (~> 3.9.0)
39
- rspec-core (3.9.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-expectations (3.9.0)
34
+ method_source (1.0.0)
35
+ minitest (5.14.4)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ pry-byebug (3.9.0)
40
+ byebug (~> 11.0)
41
+ pry (~> 0.13.0)
42
+ rake (13.0.3)
43
+ rspec (3.10.0)
44
+ rspec-core (~> 3.10.0)
45
+ rspec-expectations (~> 3.10.0)
46
+ rspec-mocks (~> 3.10.0)
47
+ rspec-core (3.10.1)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-expectations (3.10.1)
42
50
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-mocks (3.9.0)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-mocks (3.10.2)
45
53
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-support (3.9.0)
54
+ rspec-support (~> 3.10.0)
55
+ rspec-support (3.10.2)
48
56
  sqlite3 (1.3.13)
49
57
  thread_safe (0.3.6)
50
- tzinfo (1.2.5)
58
+ tzinfo (1.2.9)
51
59
  thread_safe (~> 0.1)
52
60
 
53
61
  PLATFORMS
@@ -56,11 +64,11 @@ PLATFORMS
56
64
  DEPENDENCIES
57
65
  activerecord!
58
66
  bundler
59
- byebug
60
67
  polymorphic_integer_type!
68
+ pry-byebug
61
69
  rake
62
70
  rspec
63
71
  sqlite3 (~> 1.3.6)
64
72
 
65
73
  BUNDLED WITH
66
- 1.16.1
74
+ 2.1.4
@@ -1,5 +1,5 @@
1
1
  GIT
2
- remote: git://github.com/rails/rails.git
2
+ remote: https://github.com/rails/rails.git
3
3
  revision: 663206d20aec374a28a24bb43bc7b1233042ed9b
4
4
  branch: 5-1-stable
5
5
  specs:
@@ -18,36 +18,44 @@ GIT
18
18
  PATH
19
19
  remote: ..
20
20
  specs:
21
- polymorphic_integer_type (2.2.4)
22
- activerecord
21
+ polymorphic_integer_type (3.0.0)
22
+ activerecord (< 6.1)
23
23
 
24
24
  GEM
25
25
  remote: https://rubygems.org/
26
26
  specs:
27
27
  arel (8.0.0)
28
- byebug (11.0.1)
29
- concurrent-ruby (1.1.5)
30
- diff-lcs (1.3)
31
- i18n (1.7.0)
28
+ byebug (11.1.3)
29
+ coderay (1.1.3)
30
+ concurrent-ruby (1.1.8)
31
+ diff-lcs (1.4.4)
32
+ i18n (1.8.10)
32
33
  concurrent-ruby (~> 1.0)
33
- minitest (5.13.0)
34
- rake (13.0.1)
35
- rspec (3.9.0)
36
- rspec-core (~> 3.9.0)
37
- rspec-expectations (~> 3.9.0)
38
- rspec-mocks (~> 3.9.0)
39
- rspec-core (3.9.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-expectations (3.9.0)
34
+ method_source (1.0.0)
35
+ minitest (5.14.4)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ pry-byebug (3.9.0)
40
+ byebug (~> 11.0)
41
+ pry (~> 0.13.0)
42
+ rake (13.0.3)
43
+ rspec (3.10.0)
44
+ rspec-core (~> 3.10.0)
45
+ rspec-expectations (~> 3.10.0)
46
+ rspec-mocks (~> 3.10.0)
47
+ rspec-core (3.10.1)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-expectations (3.10.1)
42
50
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-mocks (3.9.0)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-mocks (3.10.2)
45
53
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-support (3.9.0)
54
+ rspec-support (~> 3.10.0)
55
+ rspec-support (3.10.2)
48
56
  sqlite3 (1.4.2)
49
57
  thread_safe (0.3.6)
50
- tzinfo (1.2.5)
58
+ tzinfo (1.2.9)
51
59
  thread_safe (~> 0.1)
52
60
 
53
61
  PLATFORMS
@@ -56,11 +64,11 @@ PLATFORMS
56
64
  DEPENDENCIES
57
65
  activerecord!
58
66
  bundler
59
- byebug
60
67
  polymorphic_integer_type!
68
+ pry-byebug
61
69
  rake
62
70
  rspec
63
71
  sqlite3
64
72
 
65
73
  BUNDLED WITH
66
- 1.16.1
74
+ 2.1.4
@@ -1,15 +1,15 @@
1
1
  GIT
2
- remote: git://github.com/rails/rails.git
3
- revision: 892eab777c418135ce0646e91bc9ebb08a29ab9b
2
+ remote: https://github.com/rails/rails.git
3
+ revision: 48661542a2607d55f436438fe21001d262e61fec
4
4
  branch: 5-2-stable
5
5
  specs:
6
- activemodel (5.2.4.1)
7
- activesupport (= 5.2.4.1)
8
- activerecord (5.2.4.1)
9
- activemodel (= 5.2.4.1)
10
- activesupport (= 5.2.4.1)
6
+ activemodel (5.2.6)
7
+ activesupport (= 5.2.6)
8
+ activerecord (5.2.6)
9
+ activemodel (= 5.2.6)
10
+ activesupport (= 5.2.6)
11
11
  arel (>= 9.0)
12
- activesupport (5.2.4.1)
12
+ activesupport (5.2.6)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
@@ -18,36 +18,44 @@ GIT
18
18
  PATH
19
19
  remote: ..
20
20
  specs:
21
- polymorphic_integer_type (2.2.4)
22
- activerecord
21
+ polymorphic_integer_type (3.0.0)
22
+ activerecord (< 6.1)
23
23
 
24
24
  GEM
25
25
  remote: https://rubygems.org/
26
26
  specs:
27
27
  arel (9.0.0)
28
- byebug (11.0.1)
29
- concurrent-ruby (1.1.5)
30
- diff-lcs (1.3)
31
- i18n (1.7.0)
28
+ byebug (11.1.3)
29
+ coderay (1.1.3)
30
+ concurrent-ruby (1.1.8)
31
+ diff-lcs (1.4.4)
32
+ i18n (1.8.10)
32
33
  concurrent-ruby (~> 1.0)
33
- minitest (5.13.0)
34
- rake (13.0.1)
35
- rspec (3.9.0)
36
- rspec-core (~> 3.9.0)
37
- rspec-expectations (~> 3.9.0)
38
- rspec-mocks (~> 3.9.0)
39
- rspec-core (3.9.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-expectations (3.9.0)
34
+ method_source (1.0.0)
35
+ minitest (5.14.4)
36
+ pry (0.13.1)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ pry-byebug (3.9.0)
40
+ byebug (~> 11.0)
41
+ pry (~> 0.13.0)
42
+ rake (13.0.3)
43
+ rspec (3.10.0)
44
+ rspec-core (~> 3.10.0)
45
+ rspec-expectations (~> 3.10.0)
46
+ rspec-mocks (~> 3.10.0)
47
+ rspec-core (3.10.1)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-expectations (3.10.1)
42
50
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-mocks (3.9.0)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-mocks (3.10.2)
45
53
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-support (3.9.0)
54
+ rspec-support (~> 3.10.0)
55
+ rspec-support (3.10.2)
48
56
  sqlite3 (1.4.2)
49
57
  thread_safe (0.3.6)
50
- tzinfo (1.2.5)
58
+ tzinfo (1.2.9)
51
59
  thread_safe (~> 0.1)
52
60
 
53
61
  PLATFORMS
@@ -56,11 +64,11 @@ PLATFORMS
56
64
  DEPENDENCIES
57
65
  activerecord!
58
66
  bundler
59
- byebug
60
67
  polymorphic_integer_type!
68
+ pry-byebug
61
69
  rake
62
70
  rspec
63
71
  sqlite3
64
72
 
65
73
  BUNDLED WITH
66
- 1.16.1
74
+ 2.1.4
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec path: ".."
6
+
7
+ gem "activerecord", github: "rails/rails", branch: "6-0-stable"
@@ -0,0 +1,74 @@
1
+ GIT
2
+ remote: https://github.com/rails/rails.git
3
+ revision: ef97441036e0ebbe1aa2108d59c408707f998ffd
4
+ branch: 6-0-stable
5
+ specs:
6
+ activemodel (6.0.3.7)
7
+ activesupport (= 6.0.3.7)
8
+ activerecord (6.0.3.7)
9
+ activemodel (= 6.0.3.7)
10
+ activesupport (= 6.0.3.7)
11
+ activesupport (6.0.3.7)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+
18
+ PATH
19
+ remote: ..
20
+ specs:
21
+ polymorphic_integer_type (3.0.0)
22
+ activerecord (< 6.1)
23
+
24
+ GEM
25
+ remote: https://rubygems.org/
26
+ specs:
27
+ byebug (11.1.3)
28
+ coderay (1.1.3)
29
+ concurrent-ruby (1.1.8)
30
+ diff-lcs (1.4.4)
31
+ i18n (1.8.10)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (1.0.0)
34
+ minitest (5.14.4)
35
+ pry (0.13.1)
36
+ coderay (~> 1.1)
37
+ method_source (~> 1.0)
38
+ pry-byebug (3.9.0)
39
+ byebug (~> 11.0)
40
+ pry (~> 0.13.0)
41
+ rake (13.0.3)
42
+ rspec (3.10.0)
43
+ rspec-core (~> 3.10.0)
44
+ rspec-expectations (~> 3.10.0)
45
+ rspec-mocks (~> 3.10.0)
46
+ rspec-core (3.10.1)
47
+ rspec-support (~> 3.10.0)
48
+ rspec-expectations (3.10.1)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-mocks (3.10.2)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-support (3.10.2)
55
+ sqlite3 (1.4.2)
56
+ thread_safe (0.3.6)
57
+ tzinfo (1.2.9)
58
+ thread_safe (~> 0.1)
59
+ zeitwerk (2.4.2)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ activerecord!
66
+ bundler
67
+ polymorphic_integer_type!
68
+ pry-byebug
69
+ rake
70
+ rspec
71
+ sqlite3
72
+
73
+ BUNDLED WITH
74
+ 2.1.4
@@ -5,14 +5,9 @@ require "polymorphic_integer_type/extensions"
5
5
  require "polymorphic_integer_type/mapping"
6
6
  require "polymorphic_integer_type/module_generator"
7
7
  require "polymorphic_integer_type/belongs_to_polymorphic_association_extension"
8
+ require "polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension"
8
9
 
9
- if ACTIVE_RECORD_VERSION < Gem::Version.new("5")
10
- require "polymorphic_integer_type/activerecord_4/predicate_builder_extension"
11
- else
12
- require "polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension"
13
- end
14
-
15
- if ACTIVE_RECORD_VERSION >= Gem::Version.new("5.0") && ACTIVE_RECORD_VERSION < Gem::Version.new("5.2.0")
10
+ if ACTIVE_RECORD_VERSION < Gem::Version.new("5.2.0")
16
11
  require "polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension"
17
12
  end
18
13
 
@@ -1,3 +1,3 @@
1
1
  module PolymorphicIntegerType
2
- VERSION = "2.3.1"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activerecord", "< 6"
21
+ spec.add_dependency "activerecord", "< 6.1"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec"
@@ -164,7 +164,7 @@ describe PolymorphicIntegerType do
164
164
 
165
165
  context "and when it already has a polymorphic record" do
166
166
  let(:target) { kibble }
167
- before { link.update_attributes(target: target) }
167
+ before { link.update(target: target) }
168
168
 
169
169
  include_examples "proper source"
170
170
  include_examples "proper target"
@@ -178,7 +178,7 @@ describe PolymorphicIntegerType do
178
178
 
179
179
  context "and when it already has a polymorphic id and type" do
180
180
  let(:target) { kibble }
181
- before { link.update_attributes(target_id: target.id, target_type: target.class.to_s) }
181
+ before { link.update(target_id: target.id, target_type: target.class.to_s) }
182
182
  include_examples "proper source"
183
183
  include_examples "proper target"
184
184
  end
data/spec/spec_helper.rb CHANGED
@@ -18,8 +18,13 @@ RSpec.configure do |config|
18
18
  config.before(:suite) do
19
19
  database_config = YAML.load(File.open("#{File.dirname(__FILE__)}/support/database.yml"))
20
20
  ActiveRecord::Base.establish_connection(database_config)
21
- if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("5.2.0")
22
- ActiveRecord::MigrationContext.new("#{File.dirname(__FILE__)}/support/migrations").migrate
21
+
22
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) == Gem::Version.new("5.2.0")
23
+ ActiveRecord::MigrationContext.new("#{File.dirname(__FILE__)}/support/migrations").migrate
24
+ end
25
+
26
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("6.0")
27
+ ActiveRecord::MigrationContext.new("#{File.dirname(__FILE__)}/support/migrations", ActiveRecord::SchemaMigration).migrate
23
28
  end
24
29
  end
25
30
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polymorphic_integer_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-26 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '6'
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '6'
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,16 +108,15 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - bin/setup
111
- - gemfiles/Gemfile.rails-4.2-stable
112
- - gemfiles/Gemfile.rails-4.2-stable.lock
113
111
  - gemfiles/Gemfile.rails-5.0-stable
114
112
  - gemfiles/Gemfile.rails-5.0-stable.lock
115
113
  - gemfiles/Gemfile.rails-5.1-stable
116
114
  - gemfiles/Gemfile.rails-5.1-stable.lock
117
115
  - gemfiles/Gemfile.rails-5.2-stable
118
116
  - gemfiles/Gemfile.rails-5.2-stable.lock
117
+ - gemfiles/Gemfile.rails-6-0-stable
118
+ - gemfiles/Gemfile.rails-6-0-stable.lock
119
119
  - lib/polymorphic_integer_type.rb
120
- - lib/polymorphic_integer_type/activerecord_4/predicate_builder_extension.rb
121
120
  - lib/polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension.rb
122
121
  - lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb
123
122
  - lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb
@@ -150,7 +149,7 @@ homepage: ''
150
149
  licenses:
151
150
  - MIT
152
151
  metadata: {}
153
- post_install_message:
152
+ post_install_message:
154
153
  rdoc_options: []
155
154
  require_paths:
156
155
  - lib
@@ -165,9 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
167
166
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.7.9
170
- signing_key:
167
+ rubygems_version: 3.1.6
168
+ signing_key:
171
169
  specification_version: 4
172
170
  summary: Use integers rather than strings for the _type field
173
171
  test_files:
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec path: ".."
6
-
7
- gem "activerecord", github: "rails/rails", branch: "4-2-stable"
8
- gem "sqlite3", "~> 1.3.6"
@@ -1,68 +0,0 @@
1
- GIT
2
- remote: git://github.com/rails/rails.git
3
- revision: e9d6b85f3e834ceea2aeabe4cbaa96a7c73eb896
4
- branch: 4-2-stable
5
- specs:
6
- activemodel (4.2.11.1)
7
- activesupport (= 4.2.11.1)
8
- builder (~> 3.1)
9
- activerecord (4.2.11.1)
10
- activemodel (= 4.2.11.1)
11
- activesupport (= 4.2.11.1)
12
- arel (~> 6.0)
13
- activesupport (4.2.11.1)
14
- i18n (~> 0.7)
15
- minitest (~> 5.1)
16
- thread_safe (~> 0.3, >= 0.3.4)
17
- tzinfo (~> 1.1)
18
-
19
- PATH
20
- remote: ..
21
- specs:
22
- polymorphic_integer_type (2.2.4)
23
- activerecord
24
-
25
- GEM
26
- remote: https://rubygems.org/
27
- specs:
28
- arel (6.0.4)
29
- builder (3.2.4)
30
- byebug (11.0.1)
31
- concurrent-ruby (1.1.5)
32
- diff-lcs (1.3)
33
- i18n (0.9.5)
34
- concurrent-ruby (~> 1.0)
35
- minitest (5.13.0)
36
- rake (13.0.1)
37
- rspec (3.9.0)
38
- rspec-core (~> 3.9.0)
39
- rspec-expectations (~> 3.9.0)
40
- rspec-mocks (~> 3.9.0)
41
- rspec-core (3.9.0)
42
- rspec-support (~> 3.9.0)
43
- rspec-expectations (3.9.0)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.9.0)
46
- rspec-mocks (3.9.0)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.9.0)
49
- rspec-support (3.9.0)
50
- sqlite3 (1.3.13)
51
- thread_safe (0.3.6)
52
- tzinfo (1.2.5)
53
- thread_safe (~> 0.1)
54
-
55
- PLATFORMS
56
- ruby
57
-
58
- DEPENDENCIES
59
- activerecord!
60
- bundler
61
- byebug
62
- polymorphic_integer_type!
63
- rake
64
- rspec
65
- sqlite3 (~> 1.3.6)
66
-
67
- BUNDLED WITH
68
- 1.16.1
@@ -1,65 +0,0 @@
1
- module PolymorphicIntegerType
2
- module PredicateBuilderExtension
3
-
4
- # Original Code:
5
- # def self.expand(klass, table, column, value)
6
- # queries = []
7
-
8
- # # Find the foreign key when using queries such as:
9
- # # Post.where(author: author)
10
- # #
11
- # # For polymorphic relationships, find the foreign key and type:
12
- # # PriceEstimate.where(estimate_of: treasure)
13
- # if klass && reflection = klass._reflect_on_association(column)
14
- # base_class = polymorphic_base_class_from_value(value)
15
-
16
- # if reflection.polymorphic? && base_class
17
- # queries << build(table[reflection.foreign_type], base_class)
18
- # end
19
-
20
- # column = reflection.foreign_key
21
-
22
- # if base_class
23
- # primary_key = reflection.association_primary_key(base_class)
24
- # value = convert_value_to_association_ids(value, primary_key)
25
- # end
26
- # end
27
-
28
- # queries << build(table[column], value)
29
- # queries
30
- # end
31
-
32
- def expand(klass, table, column, value)
33
- queries = []
34
-
35
- # Find the foreign key when using queries such as:
36
- # Post.where(author: author)
37
- #
38
- # For polymorphic relationships, find the foreign key and type:
39
- # PriceEstimate.where(estimate_of: treasure)
40
- if klass && reflection = klass._reflect_on_association(column)
41
- base_class = polymorphic_base_class_from_value(value)
42
-
43
- if reflection.polymorphic? && base_class
44
- if klass.respond_to?("#{column}_type_mapping")
45
- queries << build(table[reflection.foreign_type], klass.send("#{column}_type_mapping").key(base_class.to_s))
46
- else
47
- queries << build(table[reflection.foreign_type], base_class)
48
- end
49
- end
50
-
51
- column = reflection.foreign_key
52
-
53
- if base_class
54
- primary_key = reflection.association_primary_key(base_class)
55
- value = convert_value_to_association_ids(value, primary_key)
56
- end
57
- end
58
-
59
- queries << build(table[column], value)
60
- queries
61
- end
62
- end
63
- end
64
-
65
- ActiveRecord::PredicateBuilder.singleton_class.prepend(PolymorphicIntegerType::PredicateBuilderExtension)