active_type 1.3.2 → 1.4.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 +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.5.2.pg.lock +2 -2
- data/lib/active_type/record_extension/inheritance.rb +18 -1
- data/lib/active_type/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8df851b9ccff70450a523e1931011b42d52b026e29969dbfdde8924809bbc66
|
4
|
+
data.tar.gz: dce25ae7f23167e775c23ebdd4cada8b2af476b2f153fdf38c388a8d78195cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65ed1343e8d7e66cc6d98a716eca941e1ae9013a9c1012dee52c550837e1687a3fd71a398ec7c30d58b1e7b21612d8c9c988fb959b126f9bca636e0fc37dec3
|
7
|
+
data.tar.gz: 3627b950fa8da92399300fcff7c735e97541b8c02311a9b33693883342a7c22cdb840dac4402108015687ba656e3d54df0e3f4b9680275c312f82782a4e9ab4f
|
data/CHANGELOG.md
CHANGED
@@ -4,10 +4,33 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
## Unreleased changes
|
6
6
|
|
7
|
+
## 1.4.0 (2020-07-27)
|
8
|
+
|
9
|
+
* Extended records now use their own I18n namespace when looking up translations for models or attributes.
|
10
|
+
If the extended record's namespace does not contain a translation, the lookup will fall back to the
|
11
|
+
base record's namespace.
|
12
|
+
|
13
|
+
For instance, given the following class hierarchy:
|
14
|
+
|
15
|
+
```
|
16
|
+
class User < ActiveRecord::Base
|
17
|
+
end
|
18
|
+
|
19
|
+
class User::Form < ActiveType::Record[User]
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
The call `ExtendedParent.human_attribute_name(:foo)` would first look up the key in
|
24
|
+
`activerecord.attributes.user/form` first, then falls back to `activerecord.attributes.user`.
|
25
|
+
|
26
|
+
Thank you @fsateler!
|
27
|
+
|
28
|
+
|
7
29
|
## 1.3.2 (2020-06-16)
|
8
30
|
|
9
31
|
* Fixed: `nests_one` association record building used empty hash instead of passed in attributes. Credit to @chriscz.
|
10
32
|
|
33
|
+
|
11
34
|
## 1.3.1 (2020-03-31)
|
12
35
|
|
13
36
|
* Fixed: Avoid #change_association breaking for polymorphic associations. Thanks to @lucthev.
|
data/Gemfile.5.2.pg.lock
CHANGED
@@ -28,7 +28,24 @@ module ActiveType
|
|
28
28
|
module ClassMethods
|
29
29
|
|
30
30
|
def model_name
|
31
|
-
|
31
|
+
@_model_name ||= begin
|
32
|
+
if name
|
33
|
+
# Namespace detection copied from ActiveModel::Naming
|
34
|
+
namespace = extended_record_base_class.parents.detect do |n|
|
35
|
+
n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
|
36
|
+
end
|
37
|
+
# We create a Name object, with the parent class name, but self as the @klass reference
|
38
|
+
# This way lookup_ancestors is invoked on the right class instead of the extended_record_base_class
|
39
|
+
dup_model_name = ActiveModel::Name.new(self, namespace, extended_record_base_class.name)
|
40
|
+
key = name.underscore
|
41
|
+
# We fake the `i18n_key` to lookup on the derived class key
|
42
|
+
# We keep the others the same to preserve parameter and route names
|
43
|
+
dup_model_name.define_singleton_method(:i18n_key) { key }
|
44
|
+
dup_model_name
|
45
|
+
else # name is nil for the anonymous intermediate class
|
46
|
+
extended_record_base_class.model_name
|
47
|
+
end
|
48
|
+
end
|
32
49
|
end
|
33
50
|
|
34
51
|
def sti_name
|
data/lib/active_type/version.rb
CHANGED
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.4.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: 2020-
|
12
|
+
date: 2020-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.0.8
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Make any Ruby object quack like ActiveRecord
|