active_type 1.4.1 → 1.4.2

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: 70a593b09da1c5389129939864d40d6ee562d2bf4b7a3bee41bbf749ba81efff
4
- data.tar.gz: e8aa031eb6aac62a71556a85c23c55ffa2ee5efa52067226306faca924c7d240
3
+ metadata.gz: dc8f689fdb28d28edb7fc550d21e0c9d4810f298da570e9e8dc223a028c09dc1
4
+ data.tar.gz: 7f41ea5cd75b455190740c263f836d42cd268e0ab15e3143c9c8dfedb21e0b04
5
5
  SHA512:
6
- metadata.gz: 3d287c42812f6afa854f608f52202c1ed6c38cd63aa6cbd7813abbad13c881e8ac333c3f5ce99503bb6c38221c19d0f858307174d37fdc84b2f74fc1b8a61fd1
7
- data.tar.gz: a966aa55504b560c99782561854487465dc7f46715b5e6deb1eb2a13fa4f016a83147b9306679936147759c2592b83aaae273f809d6f5f3ff3bca6450b49a5dd
6
+ metadata.gz: da0b114cb9f97509bc8becad66a553538cbb362d07f9c8a6f1f17d7298282c302a83f477669110fd564f269b9dda5c2a009df41d40990a030044b90be869b03e
7
+ data.tar.gz: a9c59ed853ad1972ffd1d13d73eb452945f7c882bff1bc0dec49dec26a4b59c726b14381dd7a75f3905f0a5052906d027e8f500910e9b0395e6bc6a076639193
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased changes
6
6
 
7
+ ## 1.4.2 (2020-09-17)
8
+
9
+ * Fixed: Assigning values to virtual attributes through internal setter methods (e.g. `_write_attribute`) no longer results in "can't write unknown attribute" errors.
10
+
11
+ ## 1.4.1 (2020-08-05)
12
+
13
+ * Fixed: Avoid `Module#parents` deprecation warning on Rails 6. Thanks to @cilim.
14
+
7
15
  ## 1.4.0 (2020-07-27)
8
16
 
9
17
  * Extended records now use their own I18n namespace when looking up translations for models or attributes.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -54,4 +54,4 @@ DEPENDENCIES
54
54
  rspec (~> 3.4)
55
55
 
56
56
  BUNDLED WITH
57
- 2.0.2
57
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -54,4 +54,4 @@ DEPENDENCIES
54
54
  sqlite3
55
55
 
56
56
  BUNDLED WITH
57
- 2.0.2
57
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rspec (~> 3.4)
59
59
 
60
60
  BUNDLED WITH
61
- 2.0.2
61
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rspec (~> 3.4)
59
59
 
60
60
  BUNDLED WITH
61
- 2.0.2
61
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  sqlite3
59
59
 
60
60
  BUNDLED WITH
61
- 2.0.2
61
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.4.1)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 2.0.2
59
+ 2.1.4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.3.2)
4
+ active_type (1.4.2)
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
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
@@ -144,28 +144,47 @@ module ActiveType
144
144
  @virtual_attributes_cache ||= {}
145
145
  end
146
146
 
147
- def [](name)
147
+ def read_existing_virtual_attribute(name, &block_when_not_virtual)
148
148
  if self.singleton_class._has_virtual_column?(name)
149
149
  read_virtual_attribute(name)
150
150
  else
151
- super
151
+ yield
152
152
  end
153
153
  end
154
154
 
155
- # ActiveRecord 4.2.1
156
- def _read_attribute(name)
155
+ def write_existing_virtual_attribute(name, value, &block_when_not_virtual)
157
156
  if self.singleton_class._has_virtual_column?(name)
158
- read_virtual_attribute(name)
157
+ write_virtual_attribute(name, value)
159
158
  else
160
- super
159
+ yield
160
+ end
161
+ end
162
+
163
+ def [](name)
164
+ read_existing_virtual_attribute(name) { super }
165
+ end
166
+
167
+ if ActiveRecord::VERSION::STRING >= '4.2.0'
168
+ def _read_attribute(name)
169
+ read_existing_virtual_attribute(name) { super }
170
+ end
171
+ else
172
+ def read_attribute(name)
173
+ read_existing_virtual_attribute(name) { super }
161
174
  end
162
175
  end
163
176
 
164
177
  def []=(name, value)
165
- if self.singleton_class._has_virtual_column?(name)
166
- write_virtual_attribute(name, value)
167
- else
168
- super
178
+ write_existing_virtual_attribute(name, value) { super }
179
+ end
180
+
181
+ if ActiveRecord::VERSION::STRING >= '5.2.0'
182
+ def _write_attribute(name, value)
183
+ write_existing_virtual_attribute(name, value) { super }
184
+ end
185
+ else
186
+ def write_attribute(name, value)
187
+ write_existing_virtual_attribute(name, value) { super }
169
188
  end
170
189
  end
171
190
 
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.1
4
+ version: 1.4.2
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-08-05 00:00:00.000000000 Z
12
+ date: 2020-09-17 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.0.8
126
+ rubygems_version: 3.0.3
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Make any Ruby object quack like ActiveRecord