active_type 1.3.2 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a986a7b0197d897f5ec654e3a4603de99bf814ccbad1da7541131410bf87b0a9
4
- data.tar.gz: 778020b99e23a1ffe944e3e330c0f93b87ac23d45b71df6a4522503a9856e22d
3
+ metadata.gz: e8df851b9ccff70450a523e1931011b42d52b026e29969dbfdde8924809bbc66
4
+ data.tar.gz: dce25ae7f23167e775c23ebdd4cada8b2af476b2f153fdf38c388a8d78195cb8
5
5
  SHA512:
6
- metadata.gz: 5cb4c6c1748fb677fc2957921168dfb8ad2d42ce62e8e74db3760a17baf4141e89f8b7cd1973efca740bcad84a2b37df7cd52798aafbd07f61fc209a9724bc94
7
- data.tar.gz: 861a88ad0631e0326af3c484408eac2b674f7ba4bfa1cc8c0e210be964bfa76d8d432cb7f6fd9b1536e2146ef1c6775cfedf457a7eebf020ccf1f381d706f67e
6
+ metadata.gz: f65ed1343e8d7e66cc6d98a716eca941e1ae9013a9c1012dee52c550837e1687a3fd71a398ec7c30d58b1e7b21612d8c9c988fb959b126f9bca636e0fc37dec3
7
+ data.tar.gz: 3627b950fa8da92399300fcff7c735e97541b8c02311a9b33693883342a7c22cdb840dac4402108015687ba656e3d54df0e3f4b9680275c312f82782a4e9ab4f
@@ -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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 2.0.2
59
+ 2.1.4
@@ -28,7 +28,24 @@ module ActiveType
28
28
  module ClassMethods
29
29
 
30
30
  def model_name
31
- extended_record_base_class.model_name
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
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '1.3.2'
2
+ VERSION = '1.4.0'
3
3
  end
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.3.2
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-06-16 00:00:00.000000000 Z
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.1.4
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