update_by_case 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/update_by_case/utils.rb +7 -3
- data/lib/update_by_case/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c24ec777028b299ed57e4fc0e7960d4ae5049ae149c353afc5f73df38f1fdb
|
4
|
+
data.tar.gz: '0394800fd67d436c5f0c3aa9f9a29405a5e957bc3521e1079820b1c6cd1d56de'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5fce387972a3b80c5eea0cdd6c54cac619ef968e9cf94124c3a228a146fb65830a4e0118b40775c2a25d749fe13454698bf6b7aba9652e495678344c28b6625
|
7
|
+
data.tar.gz: 0fc8ed1d9142f7ad64ef173952928f0672a87c027513da2639a47348d1ed1359b0f55a47103b3587429c82a34e2d779a5aa781fc4285fb1f447b6acfb637678c
|
data/lib/update_by_case/utils.rb
CHANGED
@@ -9,9 +9,13 @@ module UpdateByCase
|
|
9
9
|
def build_case_statement(model, attribute_name, key_attribute, cases)
|
10
10
|
case_statement = Arel::Nodes::Case.new
|
11
11
|
arel_table = model.arel_table
|
12
|
-
cases.
|
13
|
-
|
14
|
-
|
12
|
+
unless cases.empty?
|
13
|
+
cases.each do |xcase|
|
14
|
+
condition = arel_table[key_attribute].eq(xcase.first)
|
15
|
+
case_statement.when(condition).then(xcase.second)
|
16
|
+
end
|
17
|
+
else
|
18
|
+
case_statement.when(false).then(arel_table[attribute_name])
|
15
19
|
end
|
16
20
|
case_statement.else(arel_table[attribute_name])
|
17
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: update_by_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Vargas A
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pg
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|