store_attribute 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/store_attribute/active_record/store.rb +7 -8
- data/lib/store_attribute/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: 6078ba7214bee86726edd35c8cfbac054907c2aada0e5644d63b906b1884cb37
|
4
|
+
data.tar.gz: b3ac4c23dfdc1f8412fccf67fe8c7e9a441943ae7d3adba95eb735e7cd5e0302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c8b70decca97c29ec6b112265d318f7fcb598a87dccbcc6531fc7f9e1de8701830f7d963f6890cfb453704ad19b14e2b6550d9d513c33fbfadf85952a9491a4
|
7
|
+
data.tar.gz: 41a9e77501f4c9e4df33a06fa343c0377e8cb982b0dfda250003345e16d4afc635b39b99c9570ded1f7af27a6781b76c8dba013b3586bf699c048260159bf507
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.1.1 (2023-06-27)
|
6
|
+
|
7
|
+
- Lookup store attribute types only after schema load.
|
8
|
+
|
5
9
|
## 1.1.0 (2023-03-08) 🌷
|
6
10
|
|
7
11
|
- Add configuration option to return default values when attribute key is not present in the serialized value ([@markedmondson][], [@palkan][]).
|
@@ -124,7 +124,7 @@ module ActiveRecord
|
|
124
124
|
_define_predicate_method(name, prefix: prefix, suffix: suffix) if type == :boolean
|
125
125
|
|
126
126
|
_define_store_attribute(store_name) if !_local_typed_stored_attributes? || _local_typed_stored_attributes[store_name].empty?
|
127
|
-
|
127
|
+
_local_typed_stored_attributes[store_name][name] = [type, options]
|
128
128
|
end
|
129
129
|
|
130
130
|
def store_attribute_unset_values_fallback_to_default
|
@@ -138,11 +138,6 @@ module ActiveRecord
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
def _store_local_stored_attribute(store_name, key, cast_type, default: Type::TypedStore::UNDEFINED, **options) # :nodoc:
|
142
|
-
cast_type = ActiveRecord::Type.lookup(cast_type, **options) if cast_type.is_a?(Symbol)
|
143
|
-
_local_typed_stored_attributes[store_name][key] = [cast_type, default]
|
144
|
-
end
|
145
|
-
|
146
141
|
def _local_typed_stored_attributes?
|
147
142
|
instance_variable_defined?(:@local_typed_stored_attributes)
|
148
143
|
end
|
@@ -177,7 +172,9 @@ module ActiveRecord
|
|
177
172
|
type = Type::TypedStore.create_from_type(subtype)
|
178
173
|
type.owner = owner
|
179
174
|
defaultik.type = type
|
180
|
-
subtypes.each
|
175
|
+
subtypes.each do |name, (cast_type, options)|
|
176
|
+
type.add_typed_key(name, cast_type, **options.symbolize_keys)
|
177
|
+
end
|
181
178
|
|
182
179
|
define_default_attribute(attr_name, defaultik.proc, type, from_user: true)
|
183
180
|
|
@@ -191,7 +188,9 @@ module ActiveRecord
|
|
191
188
|
type = Type::TypedStore.create_from_type(subtype)
|
192
189
|
type.owner = owner
|
193
190
|
defaultik.type = type
|
194
|
-
subtypes.each
|
191
|
+
subtypes.each do |name, (cast_type, options)|
|
192
|
+
type.add_typed_key(name, cast_type, **options.symbolize_keys)
|
193
|
+
end
|
195
194
|
|
196
195
|
type
|
197
196
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.4.
|
109
|
+
rubygems_version: 3.4.8
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: ActiveRecord extension which adds typecasting to store accessors
|