Commit 1890eca
authored
BREAKING: Replace
We're removing `record_klass` at both the instance and class level. We're also removing `attribute_name` at the instance level.
In hindsight I don't think either of the instance level methods are that helpful.
Add this for full backwards compatibility though:
```ruby
ActiveRecord::AssociatedObject.alias_method :record_klass, :record
ActiveRecord::AssociatedObject.delegate :record_klass, :attribute_name, to: :class
```
Feel free to open an issue and explain how you're using these too!
----
We're also refactoring the internals here:
- We're extending ActiveModel::Naming to get `model_name` which is also useful for later features.
- We're eagerly defining the `record` and `attribute_name` methods, so people don't get `NoMethodError`'s.
- ^ but we'll still eagerly check the namespace is an `ActiveRecord::Base`` and verify it.
- We're using a double-dispatch refactoring in `associated_via` to slim `inherited` and make accessing the new object class's internals easier.
This is some of the oldest code in here, so I'm almost a little moody touching it. 😢record_klass with record & remove record_klass/attribute_name instance methods. (#35)1 parent 31f5a36 commit 1890eca
File tree
2 files changed
+20
-29
lines changed- lib/active_record
- test/active_record
2 files changed
+20
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 25 | | |
27 | | - | |
28 | | - | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 46 | + | |
50 | 47 | | |
51 | 48 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 49 | + | |
56 | 50 | | |
57 | 51 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 52 | + | |
62 | 53 | | |
63 | 54 | | |
64 | 55 | | |
| |||
0 commit comments