active_type 1.1.1 → 1.3.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 +4 -4
- data/.travis.yml +40 -16
- data/CHANGELOG.md +56 -0
- data/Gemfile.3.2.mysql2.lock +2 -2
- data/Gemfile.3.2.sqlite3.lock +2 -2
- data/Gemfile.4.2.mysql2.lock +2 -2
- data/Gemfile.4.2.pg.lock +2 -2
- data/Gemfile.4.2.sqlite3.lock +2 -2
- data/Gemfile.5.2.mysql2.lock +2 -2
- data/Gemfile.5.2.pg.lock +2 -2
- data/Gemfile.5.2.sqlite3.lock +2 -2
- data/Gemfile.6.0.pg +1 -1
- data/Gemfile.6.0.pg.lock +11 -11
- data/README.md +30 -7
- data/lib/active_type/change_association.rb +31 -0
- data/lib/active_type/nested_attributes/nests_one_association.rb +5 -2
- data/lib/active_type/no_table.rb +4 -0
- data/lib/active_type/record.rb +4 -2
- data/lib/active_type/{extended_record.rb → record_extension.rb} +3 -3
- data/lib/active_type/{extended_record → record_extension}/inheritance.rb +46 -7
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a986a7b0197d897f5ec654e3a4603de99bf814ccbad1da7541131410bf87b0a9
|
|
4
|
+
data.tar.gz: 778020b99e23a1ffe944e3e330c0f93b87ac23d45b71df6a4522503a9856e22d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5cb4c6c1748fb677fc2957921168dfb8ad2d42ce62e8e74db3760a17baf4141e89f8b7cd1973efca740bcad84a2b37df7cd52798aafbd07f61fc209a9724bc94
|
|
7
|
+
data.tar.gz: 861a88ad0631e0326af3c484408eac2b674f7ba4bfa1cc8c0e210be964bfa76d8d432cb7f6fd9b1536e2146ef1c6775cfedf457a7eebf020ccf1f381d706f67e
|
data/.travis.yml
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
dist: trusty
|
|
3
|
+
services:
|
|
4
|
+
- postgresql
|
|
2
5
|
rvm:
|
|
3
6
|
- "2.3.8"
|
|
4
|
-
- "2.4.
|
|
5
|
-
- "2.5.
|
|
7
|
+
- "2.4.6"
|
|
8
|
+
- "2.5.5"
|
|
9
|
+
- "2.6.3"
|
|
6
10
|
gemfile:
|
|
7
11
|
- Gemfile.3.2.mysql2
|
|
8
12
|
- Gemfile.3.2.sqlite3
|
|
@@ -19,30 +23,50 @@ before_script:
|
|
|
19
23
|
script: bundle exec rake spec
|
|
20
24
|
sudo: false
|
|
21
25
|
cache: bundler
|
|
22
|
-
notifications:
|
|
23
|
-
email:
|
|
24
|
-
- fail@makandra.de
|
|
25
26
|
matrix:
|
|
26
27
|
exclude:
|
|
27
|
-
- rvm: "2.
|
|
28
|
+
- rvm: "2.3.8"
|
|
29
|
+
gemfile: Gemfile.6.0.pg
|
|
30
|
+
- rvm: "2.4.6"
|
|
28
31
|
gemfile: Gemfile.3.2.mysql2
|
|
29
|
-
- rvm: "2.4.
|
|
32
|
+
- rvm: "2.4.6"
|
|
30
33
|
gemfile: Gemfile.3.2.sqlite3
|
|
31
|
-
- rvm: "2.
|
|
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"
|
|
32
45
|
gemfile: Gemfile.3.2.mysql2
|
|
33
|
-
- rvm: "2.5.
|
|
46
|
+
- rvm: "2.5.5"
|
|
34
47
|
gemfile: Gemfile.3.2.sqlite3
|
|
35
|
-
- rvm: "2.5.
|
|
48
|
+
- rvm: "2.5.5"
|
|
36
49
|
gemfile: Gemfile.4.2.mysql2
|
|
37
|
-
- rvm: "2.5.
|
|
50
|
+
- rvm: "2.5.5"
|
|
38
51
|
gemfile: Gemfile.4.2.pg
|
|
39
|
-
- rvm: "2.5.
|
|
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"
|
|
40
67
|
gemfile: Gemfile.4.2.sqlite3
|
|
41
|
-
- rvm: "2.3.8"
|
|
42
|
-
gemfile: Gemfile.6.0.pg
|
|
43
|
-
- rvm: "2.4.5"
|
|
44
|
-
gemfile: Gemfile.6.0.pg
|
|
45
68
|
install:
|
|
69
|
+
- gem install bundler:2.0.2
|
|
46
70
|
- bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
|
47
71
|
addons:
|
|
48
72
|
postgresql: 9.3
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## Unreleased changes
|
|
6
|
+
|
|
7
|
+
## 1.3.2 (2020-06-16)
|
|
8
|
+
|
|
9
|
+
* Fixed: `nests_one` association record building used empty hash instead of passed in attributes. Credit to @chriscz.
|
|
10
|
+
|
|
11
|
+
## 1.3.1 (2020-03-31)
|
|
12
|
+
|
|
13
|
+
* Fixed: Avoid #change_association breaking for polymorphic associations. Thanks to @lucthev.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 1.3.0 (2019-09-26)
|
|
17
|
+
|
|
18
|
+
* Fixed: Do not override Rails internal methods when definining an attribute called `:attribute`.
|
|
19
|
+
* Fixed: Fix .find for extended records, when a record had a `#type` column that was not used for
|
|
20
|
+
single table inheritance. Thanks to @fsateler.
|
|
21
|
+
* Changed: When extending a single table inheritance base class, `.find` no longer crashes, but
|
|
22
|
+
returns records derived from the extended class.
|
|
23
|
+
|
|
24
|
+
This means, that given the following class hierarchy:
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
class Parent < ActiveRecord::Base
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class ExtendedParent < ActiveType::Record[Parent]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Child < Parent
|
|
34
|
+
end
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
querying
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
ExtendedParent.all
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
will no longer crash, but always return records of type `ExtendedParent` (*even if they
|
|
44
|
+
would normally of type `Child`*). You should probably avoid this weird situation and not
|
|
45
|
+
extend STI Parent classes.
|
|
46
|
+
|
|
47
|
+
Thanks to @fsateler.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 1.2.1 (2019-07-03)
|
|
51
|
+
* Fixed: Eager loading in Rails 6 no longer crashes trying to load `ActiveType::Object`s.
|
|
52
|
+
Thanks to @teamhqapp for the fix.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## 1.2.0 (2019-06-18)
|
|
56
|
+
|
|
57
|
+
* Fixed: Using `has_many` et al in an extended record ignored given scopes.
|
|
58
|
+
* Added: `change_association` on ActiveType::Record to change assocation options.
|
|
59
|
+
|
|
60
|
+
|
|
5
61
|
## 1.1.1 (2019-05-07)
|
|
6
62
|
|
|
7
63
|
* Improved dirty tracking (`#changes?` etc) for virtual attributes to bring it more in line with
|
data/Gemfile.3.2.mysql2.lock
CHANGED
data/Gemfile.3.2.sqlite3.lock
CHANGED
data/Gemfile.4.2.mysql2.lock
CHANGED
data/Gemfile.4.2.pg.lock
CHANGED
data/Gemfile.4.2.sqlite3.lock
CHANGED
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
data/Gemfile.5.2.sqlite3.lock
CHANGED
data/Gemfile.6.0.pg
CHANGED
data/Gemfile.6.0.pg.lock
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
active_type (1.
|
|
4
|
+
active_type (1.3.2)
|
|
5
5
|
activerecord (>= 3.2)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
59
|
+
2.0.2
|
data/README.md
CHANGED
|
@@ -363,6 +363,31 @@ sign_up.is_a?(SignUp) # => true
|
|
|
363
363
|
```
|
|
364
364
|
|
|
365
365
|
|
|
366
|
+
Associations
|
|
367
|
+
------------
|
|
368
|
+
|
|
369
|
+
Sometimes, you have an association, and a form model for that association. Instead of always casting the associations manually, you can use the `change_association` macro to override an association's options. For example.
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
class Credential < ActiveRecord::Base
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
class User < ActiveRecord::Base
|
|
377
|
+
has_many :credentials
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
class SignUpCredential < ActiveType::Record[Credential]
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
class SignUp < ActiveType::Record[User]
|
|
384
|
+
change_association :credentials, class_name: 'SignUpCredential'
|
|
385
|
+
end
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Now, if you load `credentials`, you will automatically receive records of type `SignUpCredential`.
|
|
389
|
+
|
|
390
|
+
|
|
366
391
|
Supported Rails versions
|
|
367
392
|
------------------------
|
|
368
393
|
|
|
@@ -389,13 +414,11 @@ Now run `bundle install` and restart your server.
|
|
|
389
414
|
Development
|
|
390
415
|
-----------
|
|
391
416
|
|
|
392
|
-
- We run tests against several ActiveRecord versions.
|
|
393
|
-
- You can bundle all versions with `rake
|
|
394
|
-
- You can run specs against all
|
|
395
|
-
- You can run specs against a single
|
|
396
|
-
|
|
397
|
-
If you are getting testing failures due to Mysql trying to connect as `root` user, you can put your Mysql credentials into `spec/support/database.yml`.
|
|
398
|
-
See `spec/support/database.sample.yml` for an example.
|
|
417
|
+
- We run tests against several ActiveRecord and Ruby versions using [gemika](https://github.com/makandra/gemika).
|
|
418
|
+
- You can bundle all versions with `rake matrix:install`.
|
|
419
|
+
- You can run specs against all Gemfiles compatible with your current ruby version with `rake matrix:spec`.
|
|
420
|
+
- You can run specs against a single Gemfile with `BUNDLE_GEMFILE=Gemfile<variant> bundle exec rspec spec`.
|
|
421
|
+
- When you make a pull request, tests are automatically run against all variants and Rubies on travis.ci.
|
|
399
422
|
|
|
400
423
|
If you would like to contribute:
|
|
401
424
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module ActiveType
|
|
2
|
+
|
|
3
|
+
module ChangeAssociation
|
|
4
|
+
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
|
|
9
|
+
def change_association(association_name, new_scope, new_options = nil)
|
|
10
|
+
if (existing_association = self.reflect_on_association(association_name))
|
|
11
|
+
if new_scope.is_a?(Hash)
|
|
12
|
+
new_options = new_scope
|
|
13
|
+
new_scope = nil
|
|
14
|
+
end
|
|
15
|
+
original_options = existing_association.options
|
|
16
|
+
if ActiveRecord::VERSION::MAJOR > 3
|
|
17
|
+
new_scope ||= existing_association.scope
|
|
18
|
+
public_send(existing_association.macro, association_name, new_scope, original_options.merge(new_options))
|
|
19
|
+
else
|
|
20
|
+
public_send(existing_association.macro, association_name, original_options.merge(new_options))
|
|
21
|
+
end
|
|
22
|
+
else
|
|
23
|
+
raise ArgumentError, "unrecognized association `#{association_name}`"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -30,8 +30,11 @@ module ActiveType
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
elsif !destroy
|
|
33
|
-
assigned_child
|
|
34
|
-
|
|
33
|
+
if assigned_child
|
|
34
|
+
assigned_child.attributes = attributes
|
|
35
|
+
else
|
|
36
|
+
add_child(parent, build_child(parent, attributes))
|
|
37
|
+
end
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
|
data/lib/active_type/no_table.rb
CHANGED
data/lib/active_type/record.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'active_type/virtual_attributes'
|
|
2
|
-
require 'active_type/
|
|
2
|
+
require 'active_type/record_extension'
|
|
3
3
|
require 'active_type/nested_attributes'
|
|
4
|
+
require 'active_type/change_association'
|
|
4
5
|
|
|
5
6
|
module ActiveType
|
|
6
7
|
|
|
@@ -10,7 +11,8 @@ module ActiveType
|
|
|
10
11
|
|
|
11
12
|
include VirtualAttributes
|
|
12
13
|
include NestedAttributes
|
|
13
|
-
include
|
|
14
|
+
include RecordExtension
|
|
15
|
+
include ChangeAssociation
|
|
14
16
|
|
|
15
17
|
end
|
|
16
18
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
require 'active_type/
|
|
2
|
-
require 'active_type/extended_record/inheritance'
|
|
1
|
+
require 'active_type/record_extension/inheritance'
|
|
3
2
|
|
|
4
3
|
module ActiveType
|
|
5
4
|
|
|
6
|
-
module
|
|
5
|
+
module RecordExtension
|
|
7
6
|
|
|
8
7
|
extend ActiveSupport::Concern
|
|
9
8
|
|
|
@@ -15,6 +14,7 @@ module ActiveType
|
|
|
15
14
|
include VirtualAttributes
|
|
16
15
|
include NestedAttributes
|
|
17
16
|
include Inheritance
|
|
17
|
+
include ChangeAssociation
|
|
18
18
|
|
|
19
19
|
self.extended_record_base_class = base
|
|
20
20
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module ActiveType
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module RecordExtension
|
|
4
4
|
|
|
5
5
|
module Inheritance
|
|
6
6
|
|
|
@@ -15,10 +15,14 @@ module ActiveType
|
|
|
15
15
|
options = scope
|
|
16
16
|
scope = nil
|
|
17
17
|
end
|
|
18
|
-
unless options[:foreign_key]
|
|
18
|
+
unless options[:foreign_key] || options[:as]
|
|
19
19
|
options = options.merge(foreign_key: extended_record_base_class.name.foreign_key)
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
if ActiveRecord::VERSION::MAJOR > 3
|
|
22
|
+
[scope, options]
|
|
23
|
+
else
|
|
24
|
+
[options]
|
|
25
|
+
end
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
module ClassMethods
|
|
@@ -31,12 +35,16 @@ module ActiveType
|
|
|
31
35
|
extended_record_base_class.sti_name
|
|
32
36
|
end
|
|
33
37
|
|
|
38
|
+
def descends_from_active_record?
|
|
39
|
+
extended_record_base_class.descends_from_active_record?
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
def has_many(name, *args, &extension)
|
|
35
|
-
super(name, Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
|
|
43
|
+
super(name, *Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
|
|
36
44
|
end
|
|
37
45
|
|
|
38
46
|
def has_one(name, *args, &extension)
|
|
39
|
-
super(name, Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
|
|
47
|
+
super(name, *Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
|
|
40
48
|
end
|
|
41
49
|
|
|
42
50
|
private
|
|
@@ -45,7 +53,23 @@ module ActiveType
|
|
|
45
53
|
|
|
46
54
|
def find_sti_class(type_name)
|
|
47
55
|
sti_class = super
|
|
48
|
-
|
|
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)
|
|
49
73
|
self
|
|
50
74
|
else
|
|
51
75
|
sti_class
|
|
@@ -73,7 +97,22 @@ module ActiveType
|
|
|
73
97
|
"or overwrite #{name}.inheritance_column to use another column for that information."
|
|
74
98
|
end
|
|
75
99
|
#### our code starts here
|
|
76
|
-
|
|
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)
|
|
77
116
|
subclass = self
|
|
78
117
|
end
|
|
79
118
|
#### our code ends here
|
data/lib/active_type/version.rb
CHANGED
|
@@ -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.
|
|
4
|
+
version: 1.3.2
|
|
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:
|
|
12
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -89,8 +89,7 @@ files:
|
|
|
89
89
|
- Rakefile
|
|
90
90
|
- active_type.gemspec
|
|
91
91
|
- lib/active_type.rb
|
|
92
|
-
- lib/active_type/
|
|
93
|
-
- lib/active_type/extended_record/inheritance.rb
|
|
92
|
+
- lib/active_type/change_association.rb
|
|
94
93
|
- lib/active_type/nested_attributes.rb
|
|
95
94
|
- lib/active_type/nested_attributes/association.rb
|
|
96
95
|
- lib/active_type/nested_attributes/builder.rb
|
|
@@ -99,6 +98,8 @@ files:
|
|
|
99
98
|
- lib/active_type/no_table.rb
|
|
100
99
|
- lib/active_type/object.rb
|
|
101
100
|
- lib/active_type/record.rb
|
|
101
|
+
- lib/active_type/record_extension.rb
|
|
102
|
+
- lib/active_type/record_extension/inheritance.rb
|
|
102
103
|
- lib/active_type/type_caster.rb
|
|
103
104
|
- lib/active_type/util.rb
|
|
104
105
|
- lib/active_type/version.rb
|
|
@@ -122,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
122
123
|
- !ruby/object:Gem::Version
|
|
123
124
|
version: '0'
|
|
124
125
|
requirements: []
|
|
125
|
-
|
|
126
|
-
rubygems_version: 2.7.7
|
|
126
|
+
rubygems_version: 3.1.4
|
|
127
127
|
signing_key:
|
|
128
128
|
specification_version: 4
|
|
129
129
|
summary: Make any Ruby object quack like ActiveRecord
|