money_attribute 0.14.4 → 0.14.5

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: 8bac6640e3f2eedae550ac86db8f254b4717785dcc58c817f50284bbd15b242b
4
- data.tar.gz: fe7e0f2e4c95c83cfdaa1502389f4576737881dc306019717b4171a92637613f
3
+ metadata.gz: cd68138109c717791722388f0465c0bbd5296ffe2f30f2cb0521a74585f72483
4
+ data.tar.gz: 35b179441b1a9e8ef462fffcb0f9c4079929e3a1da6f775e82c67586dd952f2f
5
5
  SHA512:
6
- metadata.gz: a3a2eaeee424f0bca9dd1ead4a5c9dc5223cadfc9c1e492177bb261d1af9dcff4986307b56d74caf0ba09d796bc4553085c0746acbd015be583715e55e9f25d5
7
- data.tar.gz: 182594cbfe4c9d8a7b4b286d4e0e3aaeb93699858a48b1184b136aef57cfcf89e64d871d4eb0604d0109521daba5cdfb85f15da364806328223c13760c56f6bf
6
+ metadata.gz: '058e831db4a2bf193eda3117e83271c7b8ce7fa0e1be8a24dcd810e988cf7afd24fb7ed05f752a3f2368888f8051e9c117cd7311338a87a011cec80c783d2c12'
7
+ data.tar.gz: 24346e562f17164b1c1a478eca95b3e4eb38e023112a80bc5e626c6efffaf679c86ebda193fdac5f721f23304c66fcb4c4c54e68cdcb64f990bfaf88f7d9b5ca
@@ -10,6 +10,8 @@ module MoneyAttribute
10
10
  end
11
11
  end
12
12
 
13
+ # Class-level caches — written during Rails boot (single-threaded),
14
+ # read-only during request handling. Safe without synchronization.
13
15
  def self.config
14
16
  @config ||= Configuration.new
15
17
  end
@@ -10,7 +10,8 @@ module MoneyAttribute
10
10
  case amount
11
11
  when Mint::Money, NilClass then amount
12
12
  when Numeric then Mint::Money.from(amount, currency)
13
- else Mint.parse(amount, currency)
13
+ when String then Mint.parse(amount, currency)
14
+ else raise ArgumentError, "Cannot convert #{amount.inspect} (#{amount.class}) to Money"
14
15
  end
15
16
  end
16
17
  alias call parse
@@ -2,17 +2,14 @@
2
2
 
3
3
  # :nodoc
4
4
  class Numeric
5
- def to_money(currency = MoneyAttribute.default_currency) = Mint.money(self, currency)
6
-
7
- def dollars = Mint.money(self, 'USD')
8
-
9
- def euros = Mint.money(self, 'EUR')
5
+ remove_method :to_money
10
6
 
11
- alias dollar dollars
12
- alias euro euros
7
+ def to_money(currency = MoneyAttribute.default_currency) = Mint.money(self, currency)
13
8
  end
14
9
 
15
10
  # :nodoc
16
11
  class String
12
+ remove_method :to_money
13
+
17
14
  def to_money(currency = MoneyAttribute.default_currency) = Mint.parse(self, currency)
18
15
  end
@@ -4,7 +4,7 @@ module MoneyAttribute
4
4
  module FormBuilderExtension
5
5
  def money_field(method, options = {})
6
6
  money = object.public_send(method)
7
- value = money&.to_s(:currency)
7
+ value = money&.to_fs(:currency)
8
8
 
9
9
  @template.text_field_tag(field_name(method), value,
10
10
  { id: field_id(method) }.merge(options))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MoneyAttribute
4
- VERSION = '0.14.4'
4
+ VERSION = '0.14.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilson Ferraz