umbrellio-sequel-plugins 0.10.0.100 → 0.10.0.101
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 +5 -28
- data/utils/database.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fa321f3720c745f853bf852f1fbfcb430b35391ff67d48284f051ff804c3e20
|
4
|
+
data.tar.gz: 0d1d70e9f8f05173b63b62db97dfa5f4e562527d7b9e87affdbd8f2151987757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b40811232e8e9b6a711b134ae831cb05c04bc85553587bffa7bd65f0d77105ff12d0e739fa84e6048a02ca254e0782dd8bf200e488b7c9437d89c170f199862e
|
7
|
+
data.tar.gz: b8060ae4b412df5d1a459c19f5187aa27acddf8cc753465f1dd38844d8301e68e5a703a00de9530818f7d529757f4dc89aa592165542f542b3495676283c45ed
|
@@ -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
|
20
20
|
|
21
21
|
fields.each do |field|
|
22
22
|
define_store_getter(column, field)
|
@@ -26,16 +26,10 @@ module Sequel::Plugins::StoreAccessors
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def include_accessors_module
|
30
|
-
|
31
|
-
|
32
|
-
|
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 }
|
29
|
+
def include_accessors_module
|
30
|
+
return if defined?(@_store_accessors_module)
|
31
|
+
@_store_accessors_module = Module.new
|
32
|
+
include @_store_accessors_module
|
39
33
|
end
|
40
34
|
|
41
35
|
def define_store_getter(column, field)
|
@@ -54,21 +48,4 @@ module Sequel::Plugins::StoreAccessors
|
|
54
48
|
end
|
55
49
|
end
|
56
50
|
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
|
74
51
|
end
|
data/utils/database.rb
CHANGED