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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0da5a5b0b10bc0013d2a17d3b8e66054dfcd580b4eed33b5ac6036fead78173a
4
- data.tar.gz: d3e3d177f693f756fc422b6c09294424111c1fa55080c70fd5a0796e6a75afb9
3
+ metadata.gz: d3b75fc9863dd79ea23f4053b680f9ab80ad99712ca454b6ed472dba73ce1d5f
4
+ data.tar.gz: 6e0995df0f6749f92b1d156b039ab0fe94bb603ee948d2bf91436d6a25d8608c
5
5
  SHA512:
6
- metadata.gz: 52ad5a8a0eca92325705b3a618661583e387ab5b439fec46753fdac83bfaba0c4d7e159ac0c729c0f94f2fd2794d5992728291673eb7abaea0ad36012e5036fb
7
- data.tar.gz: 9c0e54821029ca1b33e6207a520daf8c2146680cee0f1a491432d17963ef72b5f577ba88d1cc195dfef2c93fe4af2df44055186720dc2506f3213ada73094f1e
6
+ metadata.gz: 946cea4cb835456c6ccd78026d56da074831e2f2fa3b77d40321e08ce1cd25ae54030cf175cf533a33b606b055c94d4e8f4beee530f3b1074b127f0e2cb033c2
7
+ data.tar.gz: 5ae594af7e7e68258edd4a12ffd218dd67187680e3d29ee5f6f0c570e4092ef0a0bdac0d842239cd19dc70799c5c929a0314003b5db93dc08443e935f86f0dab
data/config/flog.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 5.2
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
@@ -3,6 +3,6 @@
3
3
  module LB
4
4
  class Persistence
5
5
  # Version
6
- VERSION = '0.0.3'
6
+ VERSION = '0.0.4'
7
7
  end
8
8
  end
@@ -7,6 +7,9 @@ require 'rom-sql'
7
7
  require 'lb/persistence/types'
8
8
  require 'lb/persistence/settings'
9
9
 
10
+ # Helpers
11
+ require 'lb/persistence/relation/joins'
12
+
10
13
  # LB namespace
11
14
  module LB
12
15
  # Persistence
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ if ENV['COVERAGE'] == 'true'
10
10
  add_filter 'config'
11
11
  add_filter 'spec'
12
12
 
13
- minimum_coverage 100
13
+ minimum_coverage 86
14
14
  end
15
15
  end
16
16
 
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.3
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