lb-persistence 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/flog.yml +1 -1
- data/lib/lb/persistence/relation/joins.rb +37 -0
- data/lib/lb/persistence/version.rb +1 -1
- data/lib/lb/persistence.rb +3 -0
- data/spec/spec_helper.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b75fc9863dd79ea23f4053b680f9ab80ad99712ca454b6ed472dba73ce1d5f
|
4
|
+
data.tar.gz: 6e0995df0f6749f92b1d156b039ab0fe94bb603ee948d2bf91436d6a25d8608c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 946cea4cb835456c6ccd78026d56da074831e2f2fa3b77d40321e08ce1cd25ae54030cf175cf533a33b606b055c94d4e8f4beee530f3b1074b127f0e2cb033c2
|
7
|
+
data.tar.gz: 5ae594af7e7e68258edd4a12ffd218dd67187680e3d29ee5f6f0c570e4092ef0a0bdac0d842239cd19dc70799c5c929a0314003b5db93dc08443e935f86f0dab
|
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 10.4
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LB
|
4
|
+
class Persistence
|
5
|
+
module Relation
|
6
|
+
# Helper for joining relations
|
7
|
+
module Joins
|
8
|
+
def left_join_all_qualified(joins)
|
9
|
+
left_join_all(qualified, joins)
|
10
|
+
end
|
11
|
+
|
12
|
+
def left_join_all(base, joins)
|
13
|
+
join_all(:left_join, base, joins)
|
14
|
+
end
|
15
|
+
|
16
|
+
def join_all(type, base, joins)
|
17
|
+
joins.each do |relation, on|
|
18
|
+
base = base.__send__(type, relation, qualify_on(on))
|
19
|
+
end
|
20
|
+
base
|
21
|
+
end
|
22
|
+
|
23
|
+
def qualify_on(on)
|
24
|
+
on.map do |source, target|
|
25
|
+
[source.qualified, target.qualified]
|
26
|
+
end.to_h
|
27
|
+
end
|
28
|
+
|
29
|
+
def prefixed(relation,
|
30
|
+
prefix = Dry::Core::Inflector
|
31
|
+
.singularize(relation.schema.name.dataset))
|
32
|
+
relation.qualified.prefix(prefix).schema.attributes
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/lb/persistence.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lb-persistence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firas Zaidan
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lb-persistence.gemspec
|
190
190
|
- lib/lb-persistence.rb
|
191
191
|
- lib/lb/persistence.rb
|
192
|
+
- lib/lb/persistence/relation/joins.rb
|
192
193
|
- lib/lb/persistence/settings.rb
|
193
194
|
- lib/lb/persistence/types.rb
|
194
195
|
- lib/lb/persistence/version.rb
|