money_attribute 0.14.0 → 0.14.1
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 +4 -4
- data/lib/money_attribute/macro.rb +3 -3
- data/lib/money_attribute/type.rb +3 -3
- data/lib/money_attribute/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ffbcefd9c74ed5d9cce9bb96f205d17760a459e9c2d90eace2db2b564a959710
|
|
4
|
+
data.tar.gz: 4ba83f9363394f899d781dfcd90a1966a7c28a1f598cafcda298e8db0e4499d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab89258513f1f096a05f76bee51a28d64d09c03a84d3c87c7651924f80949f53015c1f1f76e8a62bb84c94fa136636e3f9f53272d23e150139b7c234e9e3ce2c
|
|
7
|
+
data.tar.gz: 828168de2168e98dadf8a5ff044359a72b45e4fb97a2106e79fd6856def5d109b44e1f0f002fe335fe97a5015438a4309c87aefb88b2550f54c2b1669df5c86f
|
|
@@ -15,7 +15,7 @@ module MoneyAttribute
|
|
|
15
15
|
if columns.include?(name) && resolved_mapping.nil?
|
|
16
16
|
define_single_column_money_attribute(name, currency)
|
|
17
17
|
else
|
|
18
|
-
define_composite_money_attribute(name, resolved_mapping)
|
|
18
|
+
define_composite_money_attribute(name, resolved_mapping, currency)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -81,11 +81,11 @@ module MoneyAttribute
|
|
|
81
81
|
|
|
82
82
|
def define_single_column_money_attribute(name, currency)
|
|
83
83
|
column_type = integer_column?(name) ? ActiveRecord::Type::Integer.new : ActiveRecord::Type::Decimal.new
|
|
84
|
-
attribute(name.to_sym, :
|
|
84
|
+
attribute(name.to_sym, :mint_money, currency:, column_type: column_type)
|
|
85
85
|
normalizes(name.to_sym, with: Converter.new(currency))
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
def define_composite_money_attribute(name, mapping)
|
|
88
|
+
def define_composite_money_attribute(name, mapping, currency)
|
|
89
89
|
aggregated = resolve_composite_for(name, mapping:)
|
|
90
90
|
|
|
91
91
|
composed_of(name.to_sym, {
|
data/lib/money_attribute/type.rb
CHANGED
|
@@ -33,9 +33,9 @@ module MoneyAttribute
|
|
|
33
33
|
return nil unless value
|
|
34
34
|
|
|
35
35
|
if @column_type.is_a?(ActiveRecord::Type::Integer)
|
|
36
|
-
|
|
36
|
+
Mint::Money.from_subunits(value, @currency)
|
|
37
37
|
else
|
|
38
|
-
|
|
38
|
+
Mint::Money.from(value, @currency)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -58,5 +58,5 @@ end
|
|
|
58
58
|
ActiveSupport.on_load(:active_record) do
|
|
59
59
|
include MoneyAttribute::Macro
|
|
60
60
|
|
|
61
|
-
ActiveRecord::Type.register(:
|
|
61
|
+
ActiveRecord::Type.register(:mint_money, MoneyAttribute::Type)
|
|
62
62
|
end
|