active_record-associated_object 0.9.1 → 0.9.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/.tool-versions +1 -1
- data/Gemfile +4 -4
- data/Gemfile.lock +76 -70
- data/README.md +16 -4
- data/lib/active_record/associated_object/version.rb +1 -1
- data/lib/active_record/associated_object.rb +11 -10
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9264143e5cc12563d395eb4922e2ca8151d632f3238428c67348182a483390c8
|
4
|
+
data.tar.gz: 6033f0a1aefe4879149c4063a25ed4303dc3f27ab7f09997a94d684f0af37827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e916c111d9d11a3b76189ae1213056026ab03a862cb4258bde73b967cef71ad7ed54a5699cf41935a45c25a7ea84dde11e587cb66ee1273db9fe1451dbbe78
|
7
|
+
data.tar.gz: 96c40ae7e7242765da0ed679a5fc032a3ef6ad7e6e2c9a0aa639ad3b7088c545232cfb27fe8bad198b86a0509262edac884c922ec2a3f424b3cbff550689e309
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.4
|
data/Gemfile
CHANGED
@@ -4,8 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem "rake"
|
8
|
-
gem "minitest"
|
7
|
+
gem "rake"
|
8
|
+
gem "minitest"
|
9
9
|
gem "debug"
|
10
10
|
|
11
11
|
gem "sqlite3"
|
@@ -14,6 +14,6 @@ gem "sqlite3"
|
|
14
14
|
gem "kredis"
|
15
15
|
gem "activejob"
|
16
16
|
gem "active_job-performs"
|
17
|
-
gem "railties"
|
17
|
+
gem "railties", "~> 7.1.0" # TODO: Remove lock after dropping 3.1 support.
|
18
18
|
|
19
|
-
gem "minitest-sprint"
|
19
|
+
gem "minitest-sprint"
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_record-associated_object (0.9.
|
4
|
+
active_record-associated_object (0.9.2)
|
5
5
|
activerecord (>= 6.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionpack (7.1.
|
11
|
-
actionview (= 7.1.
|
12
|
-
activesupport (= 7.1.
|
10
|
+
actionpack (7.1.5.1)
|
11
|
+
actionview (= 7.1.5.1)
|
12
|
+
activesupport (= 7.1.5.1)
|
13
13
|
nokogiri (>= 1.8.5)
|
14
14
|
racc
|
15
15
|
rack (>= 2.2.4)
|
@@ -17,120 +17,126 @@ GEM
|
|
17
17
|
rack-test (>= 0.6.3)
|
18
18
|
rails-dom-testing (~> 2.2)
|
19
19
|
rails-html-sanitizer (~> 1.6)
|
20
|
-
actionview (7.1.
|
21
|
-
activesupport (= 7.1.
|
20
|
+
actionview (7.1.5.1)
|
21
|
+
activesupport (= 7.1.5.1)
|
22
22
|
builder (~> 3.1)
|
23
23
|
erubi (~> 1.11)
|
24
24
|
rails-dom-testing (~> 2.2)
|
25
25
|
rails-html-sanitizer (~> 1.6)
|
26
|
-
active_job-performs (0.3.
|
26
|
+
active_job-performs (0.3.2)
|
27
27
|
activejob (>= 6.1)
|
28
|
-
activejob (7.1.
|
29
|
-
activesupport (= 7.1.
|
28
|
+
activejob (7.1.5.1)
|
29
|
+
activesupport (= 7.1.5.1)
|
30
30
|
globalid (>= 0.3.6)
|
31
|
-
activemodel (7.1.
|
32
|
-
activesupport (= 7.1.
|
33
|
-
activerecord (7.1.
|
34
|
-
activemodel (= 7.1.
|
35
|
-
activesupport (= 7.1.
|
31
|
+
activemodel (7.1.5.1)
|
32
|
+
activesupport (= 7.1.5.1)
|
33
|
+
activerecord (7.1.5.1)
|
34
|
+
activemodel (= 7.1.5.1)
|
35
|
+
activesupport (= 7.1.5.1)
|
36
36
|
timeout (>= 0.4.0)
|
37
|
-
activesupport (7.1.
|
37
|
+
activesupport (7.1.5.1)
|
38
38
|
base64
|
39
|
+
benchmark (>= 0.3)
|
39
40
|
bigdecimal
|
40
41
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
41
42
|
connection_pool (>= 2.2.5)
|
42
43
|
drb
|
43
44
|
i18n (>= 1.6, < 2)
|
45
|
+
logger (>= 1.4.2)
|
44
46
|
minitest (>= 5.1)
|
45
47
|
mutex_m
|
48
|
+
securerandom (>= 0.3)
|
46
49
|
tzinfo (~> 2.0)
|
47
50
|
base64 (0.2.0)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
benchmark (0.4.0)
|
52
|
+
bigdecimal (3.1.9)
|
53
|
+
builder (3.3.0)
|
54
|
+
concurrent-ruby (1.3.5)
|
55
|
+
connection_pool (2.5.0)
|
52
56
|
crass (1.0.6)
|
53
|
-
|
57
|
+
date (3.4.1)
|
58
|
+
debug (1.10.0)
|
54
59
|
irb (~> 1.10)
|
55
60
|
reline (>= 0.3.8)
|
56
|
-
drb (2.2.
|
57
|
-
|
58
|
-
erubi (1.12.0)
|
61
|
+
drb (2.2.1)
|
62
|
+
erubi (1.13.1)
|
59
63
|
globalid (1.2.1)
|
60
64
|
activesupport (>= 6.1)
|
61
|
-
i18n (1.14.
|
65
|
+
i18n (1.14.7)
|
62
66
|
concurrent-ruby (~> 1.0)
|
63
|
-
io-console (0.
|
64
|
-
irb (1.
|
65
|
-
|
66
|
-
|
67
|
+
io-console (0.8.0)
|
68
|
+
irb (1.15.2)
|
69
|
+
pp (>= 0.6.0)
|
70
|
+
rdoc (>= 4.0.0)
|
71
|
+
reline (>= 0.4.2)
|
67
72
|
kredis (1.7.0)
|
68
73
|
activemodel (>= 6.0.0)
|
69
74
|
activesupport (>= 6.0.0)
|
70
75
|
redis (>= 4.2, < 6)
|
71
|
-
|
76
|
+
logger (1.7.0)
|
77
|
+
loofah (2.24.0)
|
72
78
|
crass (~> 1.0.2)
|
73
79
|
nokogiri (>= 1.12.0)
|
74
|
-
minitest (5.
|
75
|
-
minitest-sprint (1.
|
80
|
+
minitest (5.25.5)
|
81
|
+
minitest-sprint (1.3.0)
|
76
82
|
path_expander (~> 1.1)
|
77
|
-
mutex_m (0.
|
78
|
-
nokogiri (1.
|
83
|
+
mutex_m (0.3.0)
|
84
|
+
nokogiri (1.18.7-arm64-darwin)
|
79
85
|
racc (~> 1.4)
|
80
|
-
nokogiri (1.
|
86
|
+
nokogiri (1.18.7-x86_64-linux-gnu)
|
81
87
|
racc (~> 1.4)
|
82
|
-
path_expander (1.1.
|
83
|
-
|
88
|
+
path_expander (1.1.3)
|
89
|
+
pp (0.6.2)
|
90
|
+
prettyprint
|
91
|
+
prettyprint (0.2.0)
|
92
|
+
psych (5.2.3)
|
93
|
+
date
|
84
94
|
stringio
|
85
|
-
racc (1.
|
86
|
-
rack (3.
|
87
|
-
rack-session (2.
|
95
|
+
racc (1.8.1)
|
96
|
+
rack (3.1.12)
|
97
|
+
rack-session (2.1.0)
|
98
|
+
base64 (>= 0.1.0)
|
88
99
|
rack (>= 3.0.0)
|
89
|
-
rack-test (2.
|
100
|
+
rack-test (2.2.0)
|
90
101
|
rack (>= 1.3)
|
91
|
-
rackup (2.1
|
102
|
+
rackup (2.2.1)
|
92
103
|
rack (>= 3)
|
93
|
-
webrick (~> 1.8)
|
94
104
|
rails-dom-testing (2.2.0)
|
95
105
|
activesupport (>= 5.0.0)
|
96
106
|
minitest
|
97
107
|
nokogiri (>= 1.6)
|
98
|
-
rails-html-sanitizer (1.6.
|
108
|
+
rails-html-sanitizer (1.6.2)
|
99
109
|
loofah (~> 2.21)
|
100
|
-
nokogiri (
|
101
|
-
railties (7.1.
|
102
|
-
actionpack (= 7.1.
|
103
|
-
activesupport (= 7.1.
|
110
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
111
|
+
railties (7.1.5.1)
|
112
|
+
actionpack (= 7.1.5.1)
|
113
|
+
activesupport (= 7.1.5.1)
|
104
114
|
irb
|
105
115
|
rackup (>= 1.0.0)
|
106
116
|
rake (>= 12.2)
|
107
117
|
thor (~> 1.0, >= 1.2.2)
|
108
118
|
zeitwerk (~> 2.6)
|
109
|
-
rake (13.1
|
110
|
-
rdoc (6.
|
119
|
+
rake (13.2.1)
|
120
|
+
rdoc (6.13.1)
|
111
121
|
psych (>= 4.0.0)
|
112
|
-
redis (5.0
|
113
|
-
redis-client (>= 0.
|
114
|
-
redis-client (0.
|
122
|
+
redis (5.4.0)
|
123
|
+
redis-client (>= 0.22.0)
|
124
|
+
redis-client (0.24.0)
|
115
125
|
connection_pool
|
116
|
-
reline (0.
|
126
|
+
reline (0.6.1)
|
117
127
|
io-console (~> 0.5)
|
118
|
-
|
119
|
-
sqlite3 (
|
120
|
-
sqlite3 (
|
121
|
-
stringio (3.1.
|
122
|
-
thor (1.3.
|
123
|
-
timeout (0.4.
|
128
|
+
securerandom (0.4.1)
|
129
|
+
sqlite3 (2.6.0-arm64-darwin)
|
130
|
+
sqlite3 (2.6.0-x86_64-linux-gnu)
|
131
|
+
stringio (3.1.6)
|
132
|
+
thor (1.3.2)
|
133
|
+
timeout (0.4.3)
|
124
134
|
tzinfo (2.0.6)
|
125
135
|
concurrent-ruby (~> 1.0)
|
126
|
-
|
127
|
-
zeitwerk (2.6.12)
|
136
|
+
zeitwerk (2.6.18)
|
128
137
|
|
129
138
|
PLATFORMS
|
130
|
-
arm64-darwin
|
131
|
-
arm64-darwin-21
|
132
|
-
arm64-darwin-22
|
133
|
-
arm64-darwin-23
|
139
|
+
arm64-darwin
|
134
140
|
x86_64-linux
|
135
141
|
|
136
142
|
DEPENDENCIES
|
@@ -139,11 +145,11 @@ DEPENDENCIES
|
|
139
145
|
activejob
|
140
146
|
debug
|
141
147
|
kredis
|
142
|
-
minitest
|
143
|
-
minitest-sprint
|
144
|
-
railties
|
145
|
-
rake
|
148
|
+
minitest
|
149
|
+
minitest-sprint
|
150
|
+
railties (~> 7.1.0)
|
151
|
+
rake
|
146
152
|
sqlite3
|
147
153
|
|
148
154
|
BUNDLED WITH
|
149
|
-
2.
|
155
|
+
2.6.7
|
data/README.md
CHANGED
@@ -65,6 +65,18 @@ We've fixed this so you don't need to care, but this is what's happening.
|
|
65
65
|
> [!TIP]
|
66
66
|
> Plural Associated Object names are also supported: `Account.has_object :seats` will look up `Account::Seats`.
|
67
67
|
|
68
|
+
> [!TIP]
|
69
|
+
> For certain names you may want to define an acronym like so:
|
70
|
+
>
|
71
|
+
> ```ruby
|
72
|
+
> # config/initializers/inflections.rb
|
73
|
+
> ActiveSupport::Inflector.inflections(:en) do |inflect|
|
74
|
+
> inflect.acronym "OAuth" # ‘oauth’ → ‘OAuth’
|
75
|
+
> end
|
76
|
+
> ```
|
77
|
+
>
|
78
|
+
> Then `has_object :oauth_scopes` will look up `OAuthScopes`, instead of `OauthScopes`.
|
79
|
+
|
68
80
|
See how we're always expecting a link to the model, here `post`?
|
69
81
|
|
70
82
|
Because of that, you can rely on `post` from the associated object:
|
@@ -87,14 +99,14 @@ end
|
|
87
99
|
|
88
100
|
### See Associated Objects in action
|
89
101
|
|
90
|
-
####
|
102
|
+
#### RubyEvents.org
|
91
103
|
|
92
|
-
The
|
104
|
+
The https://www.rubyevents.org team has been using Associated Objects to clarify the boundaries of their Active Records and collaborator Associated Objects.
|
93
105
|
|
94
106
|
See the usage in the source here:
|
95
107
|
|
96
|
-
- [`ActiveRecord::AssociatedObject` instances](https://github.com/search?q=repo%
|
97
|
-
- [`has_object` calls](https://github.com/search?q=repo%
|
108
|
+
- [`ActiveRecord::AssociatedObject` instances](https://github.com/search?q=repo%3Arubyevents%2Frubyevents%20ActiveRecord%3A%3AAssociatedObject&type=code)
|
109
|
+
- [`has_object` calls](https://github.com/search?q=repo%3Arubyevents%2Frubyevents+has_object&type=code)
|
98
110
|
|
99
111
|
#### Flipper
|
100
112
|
|
@@ -32,7 +32,10 @@ class ActiveRecord::AssociatedObject
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
|
+
def respond_to_missing?(name, ...)
|
37
|
+
(name != :abstract_class? && record.respond_to?(name, ...)) || super
|
38
|
+
end
|
36
39
|
end
|
37
40
|
|
38
41
|
module Caching
|
@@ -41,15 +44,13 @@ class ActiveRecord::AssociatedObject
|
|
41
44
|
end
|
42
45
|
delegate :cache_version, to: :record
|
43
46
|
|
44
|
-
def cache_key
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"#{model_name.cache_key}/#{id}"
|
52
|
-
end
|
47
|
+
def cache_key = case
|
48
|
+
when !record.cache_versioning?
|
49
|
+
raise "ActiveRecord::AssociatedObject#cache_key only supports #{record.class}.cache_versioning = true"
|
50
|
+
when new_record?
|
51
|
+
"#{model_name.cache_key}/new"
|
52
|
+
else
|
53
|
+
"#{model_name.cache_key}/#{id}"
|
53
54
|
end
|
54
55
|
end
|
55
56
|
include Caching
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-associated_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activerecord
|
@@ -24,7 +23,6 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '6.1'
|
27
|
-
description:
|
28
26
|
email:
|
29
27
|
- hey@kaspth.com
|
30
28
|
executables: []
|
@@ -54,7 +52,6 @@ metadata:
|
|
54
52
|
homepage_uri: https://github.com/kaspth/active_record-associated_object
|
55
53
|
source_code_uri: https://github.com/kaspth/active_record-associated_object
|
56
54
|
changelog_uri: https://github.com/kaspth/active_record-associated_object/blob/main/CHANGELOG.md
|
57
|
-
post_install_message:
|
58
55
|
rdoc_options: []
|
59
56
|
require_paths:
|
60
57
|
- lib
|
@@ -69,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
66
|
- !ruby/object:Gem::Version
|
70
67
|
version: '0'
|
71
68
|
requirements: []
|
72
|
-
rubygems_version: 3.
|
73
|
-
signing_key:
|
69
|
+
rubygems_version: 3.7.1
|
74
70
|
specification_version: 4
|
75
71
|
summary: Associate a Ruby PORO with an Active Record class and have it quack like
|
76
72
|
one.
|