umbrellio-sequel-plugins 0.10.0.86 → 0.10.0.100
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/plugins/store_accessors.rb +28 -5
- data/utils/database.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: 461c2e1edac7a90a93262bab9b44b28455d14db79872bd6b18a488da9d5f9afc
|
4
|
+
data.tar.gz: 2ea67f3af3a257f59018861b698b3c0dc7e950f7421f0db0b75c5d08081be0c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f60ef1050a1c2fd371b0525c9375ca275dd9cd2d1edff184c5df229063f24cd0dba7214cb65fe1a9380040b3ad6c226e29face260c303604087fcd9ab0dd7a
|
7
|
+
data.tar.gz: e5c02e8cd6d4c4afeb48ec2b4624fcb21d906cf40481f88a8cef556decca0e7adf3ec228b36edef23f972d50af5c5817678effb6df5dd27127f8c8ac4f3579c4
|
@@ -16,7 +16,7 @@ module Sequel::Plugins::StoreAccessors
|
|
16
16
|
# user.first_name # => "John"
|
17
17
|
# user.data # => {"first_name": "John"}
|
18
18
|
def store(column, *fields)
|
19
|
-
include_accessors_module
|
19
|
+
include_accessors_module(column)
|
20
20
|
|
21
21
|
fields.each do |field|
|
22
22
|
define_store_getter(column, field)
|
@@ -26,10 +26,16 @@ module Sequel::Plugins::StoreAccessors
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def include_accessors_module
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
def include_accessors_module(column)
|
30
|
+
unless defined?(@_store_accessors_module)
|
31
|
+
@_store_accessors_module = Module.new
|
32
|
+
include @_store_accessors_module
|
33
|
+
end
|
34
|
+
|
35
|
+
prev_columns = @_store_accessors_module.instance_variable_get(:@_store_columns) || []
|
36
|
+
new_columns = [*prev_columns, column]
|
37
|
+
@_store_accessors_module.instance_variable_set(:@_store_columns, new_columns)
|
38
|
+
@_store_accessors_module.define_method(:store_columns) { new_columns }
|
33
39
|
end
|
34
40
|
|
35
41
|
def define_store_getter(column, field)
|
@@ -48,4 +54,21 @@ module Sequel::Plugins::StoreAccessors
|
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
57
|
+
|
58
|
+
module InstanceMethods
|
59
|
+
def before_update
|
60
|
+
super
|
61
|
+
return unless respond_to?(:store_columns)
|
62
|
+
send(:store_columns).each do |store_column|
|
63
|
+
json = Sequel[store_column].pg_jsonb.concat(send(store_column))
|
64
|
+
send("#{store_column}=", json) if changed_columns.include?(store_column)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def after_update
|
69
|
+
super
|
70
|
+
return unless respond_to?(:store_columns)
|
71
|
+
reload unless send(:store_columns).all?(Hash)
|
72
|
+
end
|
73
|
+
end
|
51
74
|
end
|
data/utils/database.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrellio-sequel-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.0.
|
4
|
+
version: 0.10.0.100
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Umbrellio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
|
-
rubygems_version: 3.
|
231
|
+
rubygems_version: 3.3.5
|
232
232
|
signing_key:
|
233
233
|
specification_version: 4
|
234
234
|
summary: Sequel plugins
|