active_type 1.2.1 → 1.3.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: 0146bd11c1d9d0965e2ce93c0265c78dcdbce9e760666ce5713d055e53522f50
4
- data.tar.gz: 63eb1676ef250e2374b1da508d9e40674e52ae681743b5f30762402ebed930eb
3
+ metadata.gz: b5e4919b7989f9d2ce9468d47196b1142270e6b3c2cce7e01945c20c36f4d2b8
4
+ data.tar.gz: 258bdcde75ea6cbe3c5ef9fb55cd6b0a140a0a8e251745b6d00a0ec7af1834d5
5
5
  SHA512:
6
- metadata.gz: 52a62c1a3ec7a1f7740a651b299ac2c349b571c92eb2ec06c22c54cdb09c51074f13b62102d0b14a5b72c68daac96c3c63b06aae8f644da068835d271391f586
7
- data.tar.gz: 448e4c0fe4bdfb4ed11716387d9ec3a8713a2f7cd29caf5019bb76f124c74d00125cf0f99812483ffeb1a2005a860784c36dd5fd12af3df4dfb179573e9da9f1
6
+ metadata.gz: ccdd4e34bfbee28b18560bc03a615f52ea4b13ee8a0ba5a33fd19552a2324142108746898159f9ff81ec30cdb420c4380d72c0b695067a7c83a58450be246645
7
+ data.tar.gz: 8a91a6d3e6587f22c1dc18129f1fb35821431057d44b0732a7ab25e6f02132edcdc134b7d26735d1efbb5ae8015b33d6d055c2a6336914107b17b0f52209b0b2
@@ -4,8 +4,9 @@ services:
4
4
  - postgresql
5
5
  rvm:
6
6
  - "2.3.8"
7
- - "2.4.5"
8
- - "2.5.3"
7
+ - "2.4.6"
8
+ - "2.5.5"
9
+ - "2.6.3"
9
10
  gemfile:
10
11
  - Gemfile.3.2.mysql2
11
12
  - Gemfile.3.2.sqlite3
@@ -22,30 +23,50 @@ before_script:
22
23
  script: bundle exec rake spec
23
24
  sudo: false
24
25
  cache: bundler
25
- notifications:
26
- email:
27
- - fail@makandra.de
28
26
  matrix:
29
27
  exclude:
30
- - rvm: "2.4.5"
28
+ - rvm: "2.3.8"
29
+ gemfile: Gemfile.6.0.pg
30
+ - rvm: "2.4.6"
31
31
  gemfile: Gemfile.3.2.mysql2
32
- - rvm: "2.4.5"
32
+ - rvm: "2.4.6"
33
33
  gemfile: Gemfile.3.2.sqlite3
34
- - rvm: "2.5.3"
34
+ - rvm: "2.4.6"
35
+ gemfile: Gemfile.4.2.mysql2
36
+ - rvm: "2.4.6"
37
+ gemfile: Gemfile.4.2.pg
38
+ - rvm: "2.4.6"
39
+ gemfile: Gemfile.5.2.mysql2
40
+ - rvm: "2.4.6"
41
+ gemfile: Gemfile.5.2.pg
42
+ - rvm: "2.4.6"
43
+ gemfile: Gemfile.6.0.pg
44
+ - rvm: "2.5.5"
35
45
  gemfile: Gemfile.3.2.mysql2
36
- - rvm: "2.5.3"
46
+ - rvm: "2.5.5"
37
47
  gemfile: Gemfile.3.2.sqlite3
38
- - rvm: "2.5.3"
48
+ - rvm: "2.5.5"
39
49
  gemfile: Gemfile.4.2.mysql2
40
- - rvm: "2.5.3"
50
+ - rvm: "2.5.5"
41
51
  gemfile: Gemfile.4.2.pg
42
- - rvm: "2.5.3"
52
+ - rvm: "2.5.5"
53
+ gemfile: Gemfile.4.2.sqlite3
54
+ - rvm: "2.5.5"
55
+ gemfile: Gemfile.5.2.mysql2
56
+ - rvm: "2.5.5"
57
+ gemfile: Gemfile.5.2.pg
58
+ - rvm: "2.6.3"
59
+ gemfile: Gemfile.3.2.mysql2
60
+ - rvm: "2.6.3"
61
+ gemfile: Gemfile.3.2.sqlite3
62
+ - rvm: "2.6.3"
63
+ gemfile: Gemfile.4.2.mysql2
64
+ - rvm: "2.6.3"
65
+ gemfile: Gemfile.4.2.pg
66
+ - rvm: "2.6.3"
43
67
  gemfile: Gemfile.4.2.sqlite3
44
- - rvm: "2.3.8"
45
- gemfile: Gemfile.6.0.pg
46
- - rvm: "2.4.5"
47
- gemfile: Gemfile.6.0.pg
48
68
  install:
69
+ - gem install bundler:2.0.2
49
70
  - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
50
71
  addons:
51
72
  postgresql: 9.3
@@ -2,7 +2,42 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## Unreleased
5
+ ## Unreleased changes
6
+
7
+
8
+ ## 1.3.0 (2019-09-26)
9
+
10
+ * Fixed: Do not override Rails internal methods when definining an attribute called `:attribute`.
11
+ * Fixed: Fix .find for extended records, when a record had a `#type` column that was not used for
12
+ single table inheritance. Thanks to @fsateler.
13
+ * Changed: When extending a single table inheritance base class, `.find` no longer crashes, but
14
+ returns records derived from the extended class.
15
+
16
+ This means, that given the following class hierarchy:
17
+
18
+ ```ruby
19
+ class Parent < ActiveRecord::Base
20
+ end
21
+
22
+ class ExtendedParent < ActiveType::Record[Parent]
23
+ end
24
+
25
+ class Child < Parent
26
+ end
27
+ ```
28
+
29
+ queriying
30
+
31
+ ```
32
+ ExtendedParent.all
33
+ ```
34
+
35
+ will no longer crash, but always return records of type `ExtendedParent` (*even if they
36
+ would normally of type `Child`*). You should probably avoid this weird situation and not
37
+ extend STI Parent classes.
38
+
39
+ Thanks to @fsateler.
40
+
6
41
 
7
42
  ## 1.2.1 (2019-07-03)
8
43
  * Fixed: Eager loading in Rails 6 no longer crashes trying to load `ActiveType::Object`s.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -54,4 +54,4 @@ DEPENDENCIES
54
54
  rspec (~> 3.4)
55
55
 
56
56
  BUNDLED WITH
57
- 1.16.6
57
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -54,4 +54,4 @@ DEPENDENCIES
54
54
  sqlite3
55
55
 
56
56
  BUNDLED WITH
57
- 1.16.6
57
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rspec (~> 3.4)
59
59
 
60
60
  BUNDLED WITH
61
- 1.16.6
61
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rspec (~> 3.4)
59
59
 
60
60
  BUNDLED WITH
61
- 1.16.6
61
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  sqlite3
59
59
 
60
60
  BUNDLED WITH
61
- 1.16.6
61
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 1.16.6
59
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 1.16.6
59
+ 2.0.2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 1.16.6
59
+ 2.0.2
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord', '~>6.0.0beta'
3
+ gem 'activerecord', '~>6.0.0'
4
4
  gem 'rspec', '~>3.4'
5
5
  gem 'pg'
6
6
  gem 'rake'
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.2.1)
4
+ active_type (1.3.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.0.0.beta3)
11
- activesupport (= 6.0.0.beta3)
12
- activerecord (6.0.0.beta3)
13
- activemodel (= 6.0.0.beta3)
14
- activesupport (= 6.0.0.beta3)
15
- activesupport (6.0.0.beta3)
10
+ activemodel (6.0.0)
11
+ activesupport (= 6.0.0)
12
+ activerecord (6.0.0)
13
+ activemodel (= 6.0.0)
14
+ activesupport (= 6.0.0)
15
+ activesupport (6.0.0)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
- zeitwerk (~> 1.3, >= 1.3.1)
20
+ zeitwerk (~> 2.1, >= 2.1.8)
21
21
  concurrent-ruby (1.1.5)
22
22
  diff-lcs (1.3)
23
23
  gemika (0.3.4)
@@ -42,18 +42,18 @@ GEM
42
42
  thread_safe (0.3.6)
43
43
  tzinfo (1.2.5)
44
44
  thread_safe (~> 0.1)
45
- zeitwerk (1.4.3)
45
+ zeitwerk (2.1.9)
46
46
 
47
47
  PLATFORMS
48
48
  ruby
49
49
 
50
50
  DEPENDENCIES
51
51
  active_type!
52
- activerecord (~> 6.0.0beta)
52
+ activerecord (~> 6.0.0)
53
53
  gemika
54
54
  pg
55
55
  rake
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 1.16.6
59
+ 2.0.2
@@ -35,6 +35,10 @@ module ActiveType
35
35
  extended_record_base_class.sti_name
36
36
  end
37
37
 
38
+ def descends_from_active_record?
39
+ extended_record_base_class.descends_from_active_record?
40
+ end
41
+
38
42
  def has_many(name, *args, &extension)
39
43
  super(name, *Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
40
44
  end
@@ -49,7 +53,23 @@ module ActiveType
49
53
 
50
54
  def find_sti_class(type_name)
51
55
  sti_class = super
52
- if self <= sti_class
56
+
57
+ # Consider this class hierarchy
58
+ # class Parent < ActiveRecord::Base; end
59
+ # class Child < Parent; end
60
+ # class ExtendedParent < ActiveType::Record[Parent]; end
61
+ # class ExtendedChild < ActiveType::Record[Child]; end
62
+ if self < sti_class
63
+ # i.e. ExtendendChild.find(child.id)
64
+ # => self = ExtendedChild; sti_class = Child
65
+ # instantiate as ExtendedChild
66
+ self
67
+ elsif sti_class < extended_record_base_class
68
+ # i.e. ExtendedParent.find(child.id)
69
+ # => sti_class = Child; self = ExtendedParent; extended_record_base_class = Parent
70
+ # There is no really good solution here, since we cannot instantiate as both ExtendedParent
71
+ # and Child. We opt to instantiate as ExtendedParent, since the other option can be
72
+ # achieved by using Parent.find(child.id)
53
73
  self
54
74
  else
55
75
  sti_class
@@ -77,7 +97,22 @@ module ActiveType
77
97
  "or overwrite #{name}.inheritance_column to use another column for that information."
78
98
  end
79
99
  #### our code starts here
80
- if self <= subclass
100
+ # Consider this class hierarchy
101
+ # class Parent < ActiveRecord::Base; end
102
+ # class Child < Parent; end
103
+ # class ExtendedParent < ActiveType::Record[Parent]; end
104
+ # class ExtendedChild < ActiveType::Record[Child]; end
105
+ if self < subclass
106
+ # i.e. ExtendendChild.find(child.id)
107
+ # => self = ExtendedChild; subclass = Child
108
+ # instantiate as ExtendedChild
109
+ subclass = self
110
+ elsif subclass < extended_record_base_class
111
+ # i.e. ExtendedParent.find(child.id)
112
+ # => subclass = Child; self = ExtendedParent; extended_record_base_class = Parent
113
+ # There is no really good solution here, since we cannot instantiate as both ExtendedParent
114
+ # and Child. We opt to instantiate as ExtendedParent, since the other option can be
115
+ # achieved by using Parent.find(child.id)
81
116
  subclass = self
82
117
  end
83
118
  #### our code ends here
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -73,6 +73,8 @@ module ActiveType
73
73
 
74
74
  # Methods for compatibility with gems expecting the ActiveModel::Dirty API.
75
75
  def build_dirty_tracking_methods(name)
76
+ return if name.to_s == 'attribute' # clashes with internal methods
77
+
76
78
  @module.module_eval <<-BODY, __FILE__, __LINE__ + 1
77
79
  def #{name}_was
78
80
  virtual_attributes_were["#{name}"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-03 00:00:00.000000000 Z
12
+ date: 2019-09-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler