money_attribute 0.14.0 → 0.14.2

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: 6648e54fd55ca614b6b64674e0fe4135b6de228226056f1d39b30c9e577128c5
4
- data.tar.gz: 3416fe702dac29b141eed67555a4d94d1dd104df755966c131ef9f00f735dcc4
3
+ metadata.gz: 4f4bf2077392ed177043cba461aa559d7b468c640a83f3b61ca614bc34293cef
4
+ data.tar.gz: 4ed16b8fcc2d9496709928d2498e861102b98f1b2fd1d08059e5dc2a6a5d817a
5
5
  SHA512:
6
- metadata.gz: 6051b71da3b44a030d7af3cc44f0c9c9958bd85bf4072f95a9c103e2fa6f6eed1ed773cec56ea9c8d6e4261893c7a1a41df1f886ccd4a2b1f9af228b99cbac85
7
- data.tar.gz: e1157dd7957fd6b54649182a665aa464985bfce04a901d7e6570bf0f9e1d453fedb3407de3251a3dec79e72d2193f6e1bbcb412d3d5219a72f38244a62fb86c6
6
+ metadata.gz: fa848eaea24fd01e8ddfdef4bd6f8b16d4051f59804f94125f56fbc67c0f43106a316a61fa8d56aef0f6c1d5f8ba336160ed9e384f1e92c3428f9c59e5344138
7
+ data.tar.gz: e39def5126ef32bb6920b9e24b94a895ff2da0711c4c389c1accf2a3d82ddcf4b6df1020f5ba2e6eca7420f3579822e2b725b486d667c1f3b65d893b6827dca8
@@ -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, :money, currency:, column_type: column_type)
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, {
@@ -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
- ::Mint::Money.from_subunits(value, @currency)
36
+ Mint::Money.from_subunits(value, @currency)
37
37
  else
38
- ::Mint::Money.from(value, @currency)
38
+ Mint::Money.from(value, @currency)
39
39
  end
40
40
  end
41
41
 
@@ -49,14 +49,12 @@ module MoneyAttribute
49
49
  end
50
50
  end
51
51
 
52
- def self.type
53
- :money
54
- end
52
+ def self.type = :mint_money
55
53
  end
56
54
  end
57
55
 
58
56
  ActiveSupport.on_load(:active_record) do
59
57
  include MoneyAttribute::Macro
60
58
 
61
- ActiveRecord::Type.register(:money, MoneyAttribute::Type)
59
+ ActiveRecord::Type.register(:mint_money, MoneyAttribute::Type)
62
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MoneyAttribute
4
- VERSION = '0.14.0'
4
+ VERSION = '0.14.2'
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.0
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilson Ferraz