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: 5808a2bc3360d2922f6daafe1b3fb76fd22b7e42e55f953c9a710b6403b4d85d
4
- data.tar.gz: 3a8f0681a8ec28df623c663a2dcfac34460efab3fa022183b6b69fb3beccf2de
3
+ metadata.gz: cc64238c2cc33c623696eb7c602c81a1d6c8850495dd2e46f4eaa3039aabb85b
4
+ data.tar.gz: a7f7f743d80954eaa09c919a2cf823c28effcbac266f1e3f1a28a9b5859def15
5
5
  SHA512:
6
- metadata.gz: 99b0a1f2b1a2f66687c925cf747af3ec24af0b30847f5ac498a443e28bdc4b8e4a4b66b96211340b73d89a188a2a3bbb60363abb2e3af3a74b911077824e929f
7
- data.tar.gz: 591a1dc0d5d7db7cb016294dd0aeb1e235468e95153653348bc8a2e937830369baa9875599cbfa4864beed2cad20a41bd2ba4427e9a196cba595c2034eb4e258
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
- currency = Mint.currency(currency)
31
- return currency if config.valid_currency?(currency)
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 '#{currency.code}'. Please select a registered 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
- currencies = config.enabled_currencies == :all ? Mint.currencies : config.enabled_currencies
42
- currencies.include?(currency)
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.to_d
30
+ value&.to_d
31
31
  end
32
32
 
33
33
  def self.type
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mint
4
4
  module MoneyAttribute
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minting-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilson Ferraz