active_record-associated_object 0.7.0 → 0.8.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3be47b7b9f9789e8fec3167c2ac7ef6cf48eb835b3750475d683330e2dc3a5ca
|
4
|
+
data.tar.gz: a9236b608d99c12701007dc4c65022f64a5e09400349f04cffbf2db863357c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb726c3a240636a729997f51878a3228622d46e774a06cf6c32a8c5b2e0fea9de00066215bd2dd04af1e358aae137e34cbc96f9d89f3c7e27cf1af370c3ef21c
|
7
|
+
data.tar.gz: c2ffe5e84e7c0e1ae5666b37d326bf9400db5572aa74ec7872e4ef36acc96484c07f51b2688ed0ee533988798b127b7ce10ea6a3ae91954e63faff9279f128ab
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,6 +62,9 @@ We've fixed this so you don't need to care, but this is what's happening.
|
|
62
62
|
> [!TIP]
|
63
63
|
> You can pass multiple names too: `has_object :publisher, :classified, :fortification`. I recommend `-[i]er`, `-[i]ed` and `-ion` as the general naming conventions for your Associated Objects.
|
64
64
|
|
65
|
+
> [!TIP]
|
66
|
+
> Plural Associated Object names are also supported: `Account.has_object :seats` will look up `Account::Seats`.
|
67
|
+
|
65
68
|
See how we're always expecting a link to the model, here `post`?
|
66
69
|
|
67
70
|
Because of that, you can rely on `post` from the associated object:
|
@@ -194,6 +197,10 @@ And about a month later it was still holding up:
|
|
194
197
|
|
195
198
|
> Just checking in to say we've added like another 4 associated objects to production since my last message. `ActiveRecord::AssociatedObject` + `ActiveJob::Performs` is like a 1-2 punch super power. I'm a bit surprised that this isn't Rails core to be honest. I want to migrate so much of our code over to this. It feels much more organized and sane. Then my app/jobs folder won't have much in it because most jobs will actually be via some associated object's _later method. app/jobs will then basically be cron-type things (deactivate any expired subscriptions).
|
196
199
|
|
200
|
+
Here's what [@nshki](https://github.com/nshki) found when they tried it:
|
201
|
+
|
202
|
+
> Spent some time playing with [@kaspth](https://github.com/kaspth)'s `ActiveRecord::AssociatedObject` and `ActiveJob::Performs` and wow! The conventions these gems put in place help simplify a codebase drastically. I particularly love `ActiveJob::Performs`—it helped me refactor out all `ApplicationJob` classes I had and keep important context in the right domain model.
|
203
|
+
|
197
204
|
Let's look at testing, then we'll get to passing these POROs to jobs like the quotes mentioned!
|
198
205
|
|
199
206
|
### A Quick Aside: Testing Associated Objects
|
@@ -14,7 +14,7 @@ module ActiveRecord::AssociatedObject::ObjectAssociation
|
|
14
14
|
module ClassMethods
|
15
15
|
def has_object(*names, **callbacks)
|
16
16
|
extend_source_from(names) do |name|
|
17
|
-
"def #{name}; (@associated_objects ||= {})[:#{name}] ||= #{name.to_s.
|
17
|
+
"def #{name}; (@associated_objects ||= {})[:#{name}] ||= #{const_get(name.to_s.camelize)}.new(self); end"
|
18
18
|
end
|
19
19
|
|
20
20
|
extend_source_from(names) do |name|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-associated_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
|
-
rubygems_version: 3.5.
|
68
|
+
rubygems_version: 3.5.6
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: Associate a Ruby PORO with an Active Record class and have it quack like
|