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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd68138109c717791722388f0465c0bbd5296ffe2f30f2cb0521a74585f72483
|
|
4
|
+
data.tar.gz: 35b179441b1a9e8ef462fffcb0f9c4079929e3a1da6f775e82c67586dd952f2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '058e831db4a2bf193eda3117e83271c7b8ce7fa0e1be8a24dcd810e988cf7afd24fb7ed05f752a3f2368888f8051e9c117cd7311338a87a011cec80c783d2c12'
|
|
7
|
+
data.tar.gz: 24346e562f17164b1c1a478eca95b3e4eb38e023112a80bc5e626c6efffaf679c86ebda193fdac5f721f23304c66fcb4c4c54e68cdcb64f990bfaf88f7d9b5ca
|
|
@@ -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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
def dollars = Mint.money(self, 'USD')
|
|
8
|
-
|
|
9
|
-
def euros = Mint.money(self, 'EUR')
|
|
5
|
+
remove_method :to_money
|
|
10
6
|
|
|
11
|
-
|
|
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&.
|
|
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))
|