umbrellio-sequel-plugins 0.3.0.62 → 0.3.0.67
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/extensions/currency_rates.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5a62467c7b304dfb4e42ca312d464c3fcfecf69
|
4
|
+
data.tar.gz: 340da5aa8aa43bd09a5a231ff66a0901baa2d647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86d81572f6b945e4c75fb00636b10060b2e38b940c1482dae01e1995bf691377ab1ab64f8b07c567550fde7c4b68b28435e60fc804d818c05ef5cebba991caa6
|
7
|
+
data.tar.gz: 8e8221c2e60197c269b196ef362622a8e34dffdeec4b5c35b87b4a3d04b48b855a5a85ed68d5a387726827158aa7bf9514414fc8ae84baf93f012acdb12bdbf5
|
@@ -7,8 +7,9 @@ module Sequel
|
|
7
7
|
#
|
8
8
|
# @param aliaz [Symbol] alias to be used for joined table
|
9
9
|
# @param table [Symbol] table name to join to
|
10
|
-
# @param currency_column [Symbol] currency column by which
|
11
|
-
#
|
10
|
+
# @param currency_column [Symbol or Sequel::SQL::Expression] currency column by which
|
11
|
+
# table is joined
|
12
|
+
# @param time_column [Symbol or Sequel::SQL::Expression] time column by which table is joined
|
12
13
|
#
|
13
14
|
# @example
|
14
15
|
# Order::Model.with_rates.select(Sequel[:amount].in_usd)
|
@@ -22,8 +23,11 @@ module Sequel
|
|
22
23
|
)
|
23
24
|
table = Sequel[table]
|
24
25
|
rates = Sequel[aliaz]
|
25
|
-
|
26
|
-
|
26
|
+
|
27
|
+
currency_expr = wrap_if_symbol(currency_column, table)
|
28
|
+
time_expr = wrap_if_symbol(time_column, table)
|
29
|
+
|
30
|
+
join_expr = (rates[:currency] =~ currency_expr) & rates[:period].pg_range.contains(time_expr)
|
27
31
|
left_join(rates_table.as(aliaz), join_expr)
|
28
32
|
end
|
29
33
|
|
@@ -33,6 +37,12 @@ module Sequel
|
|
33
37
|
def table_name
|
34
38
|
respond_to?(:first_source_alias) ? first_source_alias : super
|
35
39
|
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def wrap_if_symbol(column_name, table)
|
44
|
+
column_name.is_a?(Symbol) ? table[column_name] : column_name
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
module CurrencyRateExchange
|
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.3.0.
|
4
|
+
version: 0.3.0.67
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nulldef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|