minting-rails 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc64238c2cc33c623696eb7c602c81a1d6c8850495dd2e46f4eaa3039aabb85b
|
|
4
|
+
data.tar.gz: a7f7f743d80954eaa09c919a2cf823c28effcbac266f1e3f1a28a9b5859def15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2759ac6f5abf6f77effe34aaed92629af1ce4c13ffd712c15db3103406831310cae7fad543329e6f331e135c3778c1b8ce48c4354ccdf01f5a2b655cf660eadf
|
|
7
|
+
data.tar.gz: 0d031ef7e3dcd06fc31d0eba693b9c79396325af96f1e1a6177f818c8fb8a076ca57e7159d113157f8b5451d08a7308b76ff1227124a2ea16cfac1a205165b9f
|
|
@@ -27,10 +27,11 @@ module Mint
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def self.assert_valid_currency!(currency)
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
code = currency.is_a?(Mint::Currency) ? currency.code : currency.to_s
|
|
31
|
+
currency = Mint.currency(code)
|
|
32
|
+
return currency if Mint.valid_currency?(currency)
|
|
32
33
|
|
|
33
|
-
raise ArgumentError, "Invalid currency '#{
|
|
34
|
+
raise ArgumentError, "Invalid currency '#{code}'. Please select a registered currency"
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def self.default_currency
|
|
@@ -38,7 +39,11 @@ module Mint
|
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def self.valid_currency?(currency)
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
return false if currency.nil?
|
|
43
|
+
|
|
44
|
+
code = currency.is_a?(Mint::Currency) ? currency.code : currency.to_s
|
|
45
|
+
currencies = config.enabled_currencies == :all ? Mint.currencies.keys : config.enabled_currencies
|
|
46
|
+
|
|
47
|
+
currencies.map(&:to_s).include?(code)
|
|
43
48
|
end
|
|
44
49
|
end
|
|
@@ -10,7 +10,7 @@ module Mint
|
|
|
10
10
|
|
|
11
11
|
def assert_valid_value(value)
|
|
12
12
|
case value
|
|
13
|
-
when Numeric, String
|
|
13
|
+
when NilClass, Numeric, String
|
|
14
14
|
return
|
|
15
15
|
when Mint::Money
|
|
16
16
|
return if value.currency == @currency
|
|
@@ -27,7 +27,7 @@ module Mint
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def serialize(value)
|
|
30
|
-
value
|
|
30
|
+
value&.to_d
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.type
|