polymorphic_integer_type 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +9 -9
- data/lib/polymorphic_integer_type.rb +2 -4
- data/lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb +23 -9
- data/lib/polymorphic_integer_type/{activerecord_4/belongs_to_polymorphic_association_extension.rb → belongs_to_polymorphic_association_extension.rb} +3 -1
- data/lib/polymorphic_integer_type/extensions.rb +2 -28
- data/lib/polymorphic_integer_type/mapping.rb +1 -1
- data/lib/polymorphic_integer_type/module_generator.rb +34 -0
- data/lib/polymorphic_integer_type/version.rb +1 -1
- data/polymorphic_integer_type.gemspec +2 -2
- data/spec/polymorphic_integer_type_spec.rb +54 -14
- data/spec/spec_helper.rb +3 -0
- data/spec/support/configuration.rb +2 -2
- data/spec/support/link.rb +0 -8
- data/spec/support/migrations/6_create_plant_table.rb +17 -0
- data/spec/support/migrations/7_create_activity_table.rb +15 -0
- data/spec/support/namespaced_activity.rb +11 -0
- data/spec/support/namespaced_plant.rb +11 -0
- metadata +18 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d7804d64bb9623f7c1e99d9cc3e9d87660c4aa0377dcb990d0f36116e9d0f84
|
4
|
+
data.tar.gz: 4530a6917ae04b9e5b22823551a2c999909b32406d899aad950ac26373db333a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0017c3e990e834177af622495715ea839c720bd5d511faf9675ae74820e9bff2a2cf63c7d648b7098b135b009a88a7f5a8386ee359e412f22749c77980d18939
|
7
|
+
data.tar.gz: 156289387a5dd038b1c8380b18514e78f9f3c418c0fd0fff5deb844d8a94006ea742fd3cc47ed6948cf970f3e1dde106df0a60b781b388300ed969aa5f6bdb7c
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ Rails' polymorphic associations are pretty useful. The example they give to set
|
|
6
6
|
class Picture < ActiveRecord::Base
|
7
7
|
belongs_to :imageable, polymorphic: true
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
class Employee < ActiveRecord::Base
|
11
11
|
has_many :pictures, as: :imageable
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
class Product < ActiveRecord::Base
|
15
15
|
has_many :pictures, as: :imageable
|
16
16
|
end
|
@@ -31,7 +31,7 @@ class CreatePictures < ActiveRecord::Migration
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
-
The problem with this approach is that `imageable_type` is a string (and by default it is 255 characters). This is a little ridiculous. For comparison, if we had a state machine with X states, would we describe the states with strings `"State1", "State2", etc` or would we just enumerate the state column and make it an integer? This gem will allow us to use an integer for the `imageable_type` column.
|
34
|
+
The problem with this approach is that `imageable_type` is a string (and by default it is 255 characters). This is a little ridiculous. For comparison, if we had a state machine with X states, would we describe the states with strings `"State1", "State2", etc` or would we just enumerate the state column and make it an integer? This gem will allow us to use an integer for the `imageable_type` column.
|
35
35
|
|
36
36
|
## Installation
|
37
37
|
|
@@ -60,7 +60,7 @@ class Picture < ActiveRecord::Base
|
|
60
60
|
belongs_to :imageable, polymorphic: {1 => "Employee", 2 => "Product"}
|
61
61
|
end
|
62
62
|
```
|
63
|
-
|
63
|
+
|
64
64
|
Next, include `PolymorphicIntegerType::Extensions` into any of the models that point back to the polymorphic integer type association (e.g., `Picture#imageable`) and add a [polymorphic association using `as:`](http://guides.rubyonrails.org/association_basics.html#polymorphic-associations).
|
65
65
|
|
66
66
|
```ruby
|
@@ -69,7 +69,7 @@ class Employee < ActiveRecord::Base
|
|
69
69
|
|
70
70
|
has_many :pictures, as: :imageable
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
class Product < ActiveRecord::Base
|
74
74
|
include PolymorphicIntegerType::Extensions
|
75
75
|
|
@@ -84,10 +84,10 @@ You can also store polymorphic type mappings separate from your models. This sho
|
|
84
84
|
```ruby
|
85
85
|
PolymorphicIntegerType::Mapping.configuration do |config|
|
86
86
|
config.add :imageable, {1 => "Employee", 2 => "Product" }
|
87
|
-
end
|
87
|
+
end
|
88
88
|
```
|
89
89
|
|
90
|
-
Note: The mapping here can start from whatever integer you wish, but I would advise not using 0. The reason being that if you had a new class, for instance `Avatar`, and also wanted to use this polymorphic association but forgot to include it in the mapping, it would effectively get `to_i` called on it and stored in the database. `"Avatar".to_i == 0`, so if your mapping included 0, this would create a weird bug.
|
90
|
+
Note: The mapping here can start from whatever integer you wish, but I would advise not using 0. The reason being that if you had a new class, for instance `Avatar`, and also wanted to use this polymorphic association but forgot to include it in the mapping, it would effectively get `to_i` called on it and stored in the database. `"Avatar".to_i == 0`, so if your mapping included 0, this would create a weird bug.
|
91
91
|
|
92
92
|
### Migrating an existing association
|
93
93
|
|
@@ -95,14 +95,14 @@ If you want to convert a polymorphic association that is already a string, you'l
|
|
95
95
|
|
96
96
|
```ruby
|
97
97
|
class PictureToPolymorphicIntegerType < ActiveRecord::Migration
|
98
|
-
|
98
|
+
|
99
99
|
def up
|
100
100
|
change_table :pictures do |t|
|
101
101
|
t.integer :new_imageable_type
|
102
102
|
end
|
103
103
|
|
104
104
|
execute <<-SQL
|
105
|
-
UPDATE
|
105
|
+
UPDATE picture
|
106
106
|
SET new_imageable_type = CASE imageable_type
|
107
107
|
WHEN 'Employee' THEN 1
|
108
108
|
WHEN 'Product' THEN 2
|
@@ -3,6 +3,8 @@ ACTIVE_RECORD_VERSION = Gem::Version.new(ActiveRecord::VERSION::STRING)
|
|
3
3
|
require "polymorphic_integer_type/version"
|
4
4
|
require "polymorphic_integer_type/extensions"
|
5
5
|
require "polymorphic_integer_type/mapping"
|
6
|
+
require "polymorphic_integer_type/module_generator"
|
7
|
+
require "polymorphic_integer_type/belongs_to_polymorphic_association_extension"
|
6
8
|
|
7
9
|
if ACTIVE_RECORD_VERSION < Gem::Version.new("5")
|
8
10
|
require "polymorphic_integer_type/activerecord_4/predicate_builder_extension"
|
@@ -14,8 +16,4 @@ if ACTIVE_RECORD_VERSION >= Gem::Version.new("5.0") && ACTIVE_RECORD_VERSION < G
|
|
14
16
|
require "polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension"
|
15
17
|
end
|
16
18
|
|
17
|
-
if ACTIVE_RECORD_VERSION < Gem::Version.new("5.2.0")
|
18
|
-
require "polymorphic_integer_type/activerecord_4/belongs_to_polymorphic_association_extension"
|
19
|
-
end
|
20
|
-
|
21
19
|
module PolymorphicIntegerType; end
|
@@ -1,17 +1,31 @@
|
|
1
1
|
module PolymorphicIntegerType
|
2
2
|
module PolymorphicArrayValueExtension
|
3
|
+
|
4
|
+
# original method:
|
5
|
+
# def type_to_ids_mapping
|
6
|
+
# default_hash = Hash.new { |hsh, key| hsh[key] = [] }
|
7
|
+
# result = values.each_with_object(default_hash) do |value, hash|
|
8
|
+
# hash[klass(value).polymorphic_name] << convert_to_id(value)
|
9
|
+
# end
|
10
|
+
# end
|
11
|
+
|
3
12
|
def type_to_ids_mapping
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
13
|
+
association = @associated_table.send(:association)
|
14
|
+
name = association.name
|
15
|
+
default_hash = Hash.new { |hsh, key| hsh[key] = [] }
|
16
|
+
values.each_with_object(default_hash) do |value, hash|
|
17
|
+
klass = respond_to?(:klass, true) ? klass(value) : value.class
|
18
|
+
if association.active_record.respond_to?("#{name}_type_mapping")
|
19
|
+
mapping = association.active_record.send("#{name}_type_mapping")
|
20
|
+
key ||= mapping.key(klass.polymorphic_name) if klass.respond_to?(:polymorphic_name)
|
21
|
+
key ||= mapping.key(klass.sti_name)
|
22
|
+
key ||= mapping.key(klass.base_class.to_s)
|
23
|
+
key ||= mapping.key(klass.base_class.sti_name)
|
8
24
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
25
|
+
hash[key] << convert_to_id(value)
|
26
|
+
else
|
27
|
+
hash[klass.polymorphic_name] << convert_to_id(value)
|
13
28
|
end
|
14
|
-
result
|
15
29
|
end
|
16
30
|
end
|
17
31
|
end
|
@@ -3,7 +3,9 @@ module ActiveRecord
|
|
3
3
|
class BelongsToPolymorphicAssociation < BelongsToAssociation
|
4
4
|
private def replace_keys(record)
|
5
5
|
super
|
6
|
-
|
6
|
+
unless record.nil?
|
7
|
+
owner[reflection.foreign_type] = record.class.base_class
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
@@ -20,37 +20,11 @@ module PolymorphicIntegerType
|
|
20
20
|
_polymorphic_foreign_types << foreign_type
|
21
21
|
|
22
22
|
# Required way to dynamically define a class method on the model
|
23
|
-
|
23
|
+
define_singleton_method("#{foreign_type}_mapping") do
|
24
24
|
mapping
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
define_method foreign_type do
|
29
|
-
t = super()
|
30
|
-
self.class.send("#{foreign_type}_mapping")[t]
|
31
|
-
end
|
32
|
-
|
33
|
-
define_method "#{foreign_type}=" do |klass|
|
34
|
-
mapping = self.class.send("#{foreign_type}_mapping")
|
35
|
-
enum = mapping.key(klass.to_s)
|
36
|
-
if klass.kind_of?(Class) && klass <= ActiveRecord::Base
|
37
|
-
enum ||= mapping.key(klass.polymorphic_name) if klass.respond_to?(:polymorphic_name)
|
38
|
-
enum ||= mapping.key(klass.sti_name)
|
39
|
-
enum ||= mapping.key(klass.base_class.to_s)
|
40
|
-
enum ||= mapping.key(klass.base_class.sti_name)
|
41
|
-
end
|
42
|
-
enum ||= klass if klass != NilClass
|
43
|
-
super(enum)
|
44
|
-
end
|
45
|
-
|
46
|
-
define_method "#{name}=" do |record|
|
47
|
-
super(record)
|
48
|
-
send("#{foreign_type}=", record.class)
|
49
|
-
association(name).loaded!
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
include(foreign_type_extension)
|
27
|
+
ModuleGenerator.generate_and_include(self, foreign_type, name)
|
54
28
|
|
55
29
|
validate do
|
56
30
|
t = send(foreign_type)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module PolymorphicIntegerType
|
2
|
+
class ModuleGenerator
|
3
|
+
def self.generate_and_include(klass,foreign_type, name)
|
4
|
+
foreign_type_extension = Module.new do
|
5
|
+
define_method foreign_type do
|
6
|
+
t = super()
|
7
|
+
self.class.send("#{foreign_type}_mapping")[t]
|
8
|
+
end
|
9
|
+
|
10
|
+
define_method "#{foreign_type}=" do |klass|
|
11
|
+
mapping = self.class.send("#{foreign_type}_mapping")
|
12
|
+
enum = mapping.key(klass.to_s)
|
13
|
+
if klass.kind_of?(Class) && klass <= ActiveRecord::Base
|
14
|
+
enum ||= mapping.key(klass.polymorphic_name) if klass.respond_to?(:polymorphic_name)
|
15
|
+
enum ||= mapping.key(klass.sti_name)
|
16
|
+
enum ||= mapping.key(klass.base_class.to_s)
|
17
|
+
enum ||= mapping.key(klass.base_class.sti_name)
|
18
|
+
end
|
19
|
+
enum ||= klass if klass != NilClass
|
20
|
+
super(enum)
|
21
|
+
end
|
22
|
+
|
23
|
+
define_method "#{name}=" do |record|
|
24
|
+
super(record)
|
25
|
+
send("#{foreign_type}=", record.class)
|
26
|
+
association(name).loaded!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
klass.include(foreign_type_extension)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -18,10 +18,10 @@ 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"
|
21
|
+
spec.add_dependency "activerecord", "< 6"
|
22
22
|
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
25
|
spec.add_development_dependency "sqlite3"
|
26
|
-
spec.add_development_dependency "byebug"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
27
27
|
end
|
@@ -14,6 +14,50 @@ describe PolymorphicIntegerType do
|
|
14
14
|
|
15
15
|
let(:link) { Link.create(source: source, target: target) }
|
16
16
|
|
17
|
+
|
18
|
+
context "when creating associations" do
|
19
|
+
it "sets the source_type" do
|
20
|
+
link = dog.source_links.new
|
21
|
+
expect(link.source_type).to eq("Animal")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets the target_type" do
|
25
|
+
link = kibble.target_links.new
|
26
|
+
expect(link.target_type).to eq("Food")
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when models are namespaced" do
|
30
|
+
context "and mappings include namespaces" do
|
31
|
+
it "sets the source_type" do
|
32
|
+
allow(Link).to receive(:source_type_mapping).and_return({3 => "Namespaced::Plant"})
|
33
|
+
allow(Link).to receive(:source_type_mapping2).and_return({3 => "Namespaced::Plant"})
|
34
|
+
|
35
|
+
link = Namespaced::Plant.create(name: "Oak").source_links.new
|
36
|
+
expect(link.source_type).to eq("Namespaced::Plant")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "sets the target_type" do
|
40
|
+
allow(Link).to receive(:target_type_mapping).and_return({3 => "Namespaced::Activity"})
|
41
|
+
link = Namespaced::Activity.create(name: "swaying").target_links.new
|
42
|
+
expect(link.target_type).to eq("Namespaced::Activity")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "and mappings don't include namespaces" do
|
47
|
+
it "sets the source type" do
|
48
|
+
Link.source_type_mapping
|
49
|
+
link = Namespaced::Plant.create(name: "Oak").source_links.new
|
50
|
+
expect(link.source_type).to eq("Plant")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "sets the target type" do
|
54
|
+
link = Namespaced::Activity.create(name:"swaying").target_links.new
|
55
|
+
expect(link.target_type).to eq("Activity")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
17
61
|
context "when the source is nil" do
|
18
62
|
let(:source) { nil }
|
19
63
|
let(:target) { nil }
|
@@ -73,6 +117,15 @@ describe PolymorphicIntegerType do
|
|
73
117
|
it "properly finds the object with a find_by" do
|
74
118
|
expect(Link.find_by(source: source, id: link.id)).to eql link
|
75
119
|
end
|
120
|
+
|
121
|
+
context "when source and target are namespaced without modifying polymorphic_name" do
|
122
|
+
it "properly finds the object" do
|
123
|
+
plant = Namespaced::Plant.create(name: "Mighty", kind: "Oak", owner: owner)
|
124
|
+
activity = Namespaced::Activity.create(name: "swaying")
|
125
|
+
link = Link.create(source: plant, target: activity)
|
126
|
+
expect(Link.where(source: plant, id: link.id).first).to eql link
|
127
|
+
end
|
128
|
+
end
|
76
129
|
end
|
77
130
|
|
78
131
|
shared_examples "proper source" do
|
@@ -103,7 +156,6 @@ describe PolymorphicIntegerType do
|
|
103
156
|
expect(source.source_links[0].source).to eql source
|
104
157
|
end
|
105
158
|
end
|
106
|
-
|
107
159
|
end
|
108
160
|
context "When a link is given polymorphic record" do
|
109
161
|
let(:link) { Link.create(source: source) }
|
@@ -116,9 +168,7 @@ describe PolymorphicIntegerType do
|
|
116
168
|
|
117
169
|
include_examples "proper source"
|
118
170
|
include_examples "proper target"
|
119
|
-
|
120
171
|
end
|
121
|
-
|
122
172
|
end
|
123
173
|
|
124
174
|
context "When a link is given polymorphic id and type" do
|
@@ -131,9 +181,7 @@ describe PolymorphicIntegerType do
|
|
131
181
|
before { link.update_attributes(target_id: target.id, target_type: target.class.to_s) }
|
132
182
|
include_examples "proper source"
|
133
183
|
include_examples "proper target"
|
134
|
-
|
135
184
|
end
|
136
|
-
|
137
185
|
end
|
138
186
|
|
139
187
|
context "When using a relation to the links with eager loading" do
|
@@ -146,9 +194,7 @@ describe PolymorphicIntegerType do
|
|
146
194
|
it "should be able to return the links and the targets" do
|
147
195
|
expect(cat.source_links).to match_array links
|
148
196
|
expect(cat.source_links.includes(:target).collect(&:target)).to match_array [water, kibble]
|
149
|
-
|
150
197
|
end
|
151
|
-
|
152
198
|
end
|
153
199
|
|
154
200
|
context "When using a through relation to the links with eager loading" do
|
@@ -161,9 +207,7 @@ describe PolymorphicIntegerType do
|
|
161
207
|
it "should be able to return the links and the targets" do
|
162
208
|
expect(owner.pet_source_links).to match_array links
|
163
209
|
expect(owner.pet_source_links.includes(:target).collect(&:target)).to match_array [water, kibble]
|
164
|
-
|
165
210
|
end
|
166
|
-
|
167
211
|
end
|
168
212
|
|
169
213
|
context "When eager loading the polymorphic association" do
|
@@ -178,16 +222,12 @@ describe PolymorphicIntegerType do
|
|
178
222
|
expect(links.first.source).to eql cat
|
179
223
|
expect(links.last.source).to eql dog
|
180
224
|
end
|
181
|
-
|
182
225
|
end
|
183
226
|
|
184
227
|
it "should be able to preload the association" do
|
185
228
|
l = Link.includes(:source).where(id: link.id).first
|
186
229
|
expect(l.source).to eql cat
|
187
230
|
end
|
188
|
-
|
189
|
-
|
190
|
-
|
191
231
|
end
|
192
232
|
|
193
233
|
context "when the association is an STI table" do
|
@@ -239,7 +279,7 @@ describe PolymorphicIntegerType do
|
|
239
279
|
include_examples "proper target"
|
240
280
|
|
241
281
|
it "creates foreign_type mapping method" do
|
242
|
-
expect(Link.source_type_mapping).to eq({1 => "Person", 2 => "Animal"})
|
282
|
+
expect(Link.source_type_mapping).to eq({1 => "Person", 2 => "Animal", 3 => "Plant"})
|
243
283
|
expect(InlineLink.source_type_mapping).to eq({10 => "Person", 11 => "InlineAnimal"})
|
244
284
|
end
|
245
285
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,11 +5,14 @@ require 'support/configuration'
|
|
5
5
|
require 'support/link'
|
6
6
|
require 'support/animal'
|
7
7
|
require 'support/namespaced_animal'
|
8
|
+
require 'support/namespaced_plant'
|
8
9
|
require 'support/dog'
|
9
10
|
require 'support/person'
|
10
11
|
require 'support/food'
|
11
12
|
require 'support/drink'
|
13
|
+
require 'support/namespaced_activity'
|
12
14
|
require 'byebug'
|
15
|
+
require 'pry'
|
13
16
|
|
14
17
|
RSpec.configure do |config|
|
15
18
|
config.before(:suite) do
|
@@ -1,4 +1,4 @@
|
|
1
1
|
PolymorphicIntegerType::Mapping.configuration do |config|
|
2
|
-
config.add :source, {1 => "Person", 2 => "Animal"}
|
3
|
-
config.add :target, {1 => "Food", 2 => "Drink"}
|
2
|
+
config.add :source, {1 => "Person", 2 => "Animal", 3 => "Plant"}
|
3
|
+
config.add :target, {1 => "Food", 2 => "Drink", 3 => "Activity"}
|
4
4
|
end
|
data/spec/support/link.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Namespaced
|
2
|
+
class Activity < ActiveRecord::Base
|
3
|
+
include PolymorphicIntegerType::Extensions
|
4
|
+
|
5
|
+
self.store_full_sti_class = false
|
6
|
+
self.table_name = "activities"
|
7
|
+
|
8
|
+
has_many :target_links, as: :target, inverse_of: :target, integer_type: true, class_name: "Link"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Namespaced
|
2
|
+
class Plant < ActiveRecord::Base
|
3
|
+
include PolymorphicIntegerType::Extensions
|
4
|
+
|
5
|
+
self.store_full_sti_class = false
|
6
|
+
self.table_name = "plants"
|
7
|
+
|
8
|
+
belongs_to :owner, class_name: "Person"
|
9
|
+
has_many :source_links, as: :source, inverse_of: :source, integer_type: true, class_name: "Link"
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polymorphic_integer_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle d'Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
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: '
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: byebug
|
84
|
+
name: pry-byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -117,12 +117,13 @@ files:
|
|
117
117
|
- gemfiles/Gemfile.rails-5.2-stable
|
118
118
|
- gemfiles/Gemfile.rails-5.2-stable.lock
|
119
119
|
- lib/polymorphic_integer_type.rb
|
120
|
-
- lib/polymorphic_integer_type/activerecord_4/belongs_to_polymorphic_association_extension.rb
|
121
120
|
- lib/polymorphic_integer_type/activerecord_4/predicate_builder_extension.rb
|
122
121
|
- lib/polymorphic_integer_type/activerecord_5_0_0/association_query_handler_extension.rb
|
123
122
|
- lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb
|
123
|
+
- lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb
|
124
124
|
- lib/polymorphic_integer_type/extensions.rb
|
125
125
|
- lib/polymorphic_integer_type/mapping.rb
|
126
|
+
- lib/polymorphic_integer_type/module_generator.rb
|
126
127
|
- lib/polymorphic_integer_type/version.rb
|
127
128
|
- polymorphic_integer_type.gemspec
|
128
129
|
- spec/polymorphic_integer_type_spec.rb
|
@@ -139,7 +140,11 @@ files:
|
|
139
140
|
- spec/support/migrations/3_create_person_table.rb
|
140
141
|
- spec/support/migrations/4_create_food_table.rb
|
141
142
|
- spec/support/migrations/5_create_drink_table.rb
|
143
|
+
- spec/support/migrations/6_create_plant_table.rb
|
144
|
+
- spec/support/migrations/7_create_activity_table.rb
|
145
|
+
- spec/support/namespaced_activity.rb
|
142
146
|
- spec/support/namespaced_animal.rb
|
147
|
+
- spec/support/namespaced_plant.rb
|
143
148
|
- spec/support/person.rb
|
144
149
|
homepage: ''
|
145
150
|
licenses:
|
@@ -161,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
166
|
version: '0'
|
162
167
|
requirements: []
|
163
168
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.7.9
|
165
170
|
signing_key:
|
166
171
|
specification_version: 4
|
167
172
|
summary: Use integers rather than strings for the _type field
|
@@ -180,5 +185,9 @@ test_files:
|
|
180
185
|
- spec/support/migrations/3_create_person_table.rb
|
181
186
|
- spec/support/migrations/4_create_food_table.rb
|
182
187
|
- spec/support/migrations/5_create_drink_table.rb
|
188
|
+
- spec/support/migrations/6_create_plant_table.rb
|
189
|
+
- spec/support/migrations/7_create_activity_table.rb
|
190
|
+
- spec/support/namespaced_activity.rb
|
183
191
|
- spec/support/namespaced_animal.rb
|
192
|
+
- spec/support/namespaced_plant.rb
|
184
193
|
- spec/support/person.rb
|