money 6.13.5 → 6.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.
@@ -347,7 +347,7 @@ class Money
347
347
  end
348
348
 
349
349
  def format_decimal_part(value)
350
- return nil if currency.decimal_places == 0 && !Money.infinite_precision
350
+ return nil if currency.decimal_places == 0 && !Money.default_infinite_precision
351
351
  return nil if rules[:no_cents]
352
352
  return nil if rules[:no_cents_if_whole] && value.to_i == 0
353
353
 
@@ -79,6 +79,8 @@ class Money
79
79
  end
80
80
 
81
81
  def determine_format_from_formatting_rules(rules)
82
+ return currency.format if currency.format && !rules.has_key?(:symbol_position)
83
+
82
84
  symbol_position = symbol_position_from(rules)
83
85
 
84
86
  if symbol_position == :before
@@ -19,7 +19,7 @@ class Money
19
19
  #
20
20
  # @param [Hash] opts Optional store options.
21
21
  # @option opts [Boolean] :without_mutex disables the usage of a mutex
22
- # @param [Hash] rt Optional initial exchange rate data.
22
+ # @param [Hash] rates Optional initial exchange rate data.
23
23
  def initialize(opts = {}, rates = {})
24
24
  @rates = rates
25
25
  @options = opts
@@ -39,8 +39,8 @@ class Money
39
39
  # store.add_rate("USD", "CAD", 1.24515)
40
40
  # store.add_rate("CAD", "USD", 0.803115)
41
41
  def add_rate(currency_iso_from, currency_iso_to, rate)
42
- @guard.synchronize do
43
- @rates[rate_key_for(currency_iso_from, currency_iso_to)] = rate
42
+ guard.synchronize do
43
+ rates[rate_key_for(currency_iso_from, currency_iso_to)] = rate
44
44
  end
45
45
  end
46
46
 
@@ -58,20 +58,20 @@ class Money
58
58
  #
59
59
  # store.get_rate("USD", "CAD") #=> 1.24515
60
60
  def get_rate(currency_iso_from, currency_iso_to)
61
- @guard.synchronize do
62
- @rates[rate_key_for(currency_iso_from, currency_iso_to)]
61
+ guard.synchronize do
62
+ rates[rate_key_for(currency_iso_from, currency_iso_to)]
63
63
  end
64
64
  end
65
65
 
66
66
  def marshal_dump
67
- @guard.synchronize do
68
- return [self.class, @options, @rates.dup]
67
+ guard.synchronize do
68
+ return [self.class, options, rates.dup]
69
69
  end
70
70
  end
71
71
 
72
72
  # Wraps block execution in a thread-safe transaction
73
73
  def transaction(&block)
74
- @guard.synchronize do
74
+ guard.synchronize do
75
75
  yield
76
76
  end
77
77
  end
@@ -91,8 +91,8 @@ class Money
91
91
  def each_rate(&block)
92
92
  return to_enum(:each_rate) unless block_given?
93
93
 
94
- @guard.synchronize do
95
- @rates.each do |key, rate|
94
+ guard.synchronize do
95
+ rates.each do |key, rate|
96
96
  iso_from, iso_to = key.split(INDEX_KEY_SEPARATOR)
97
97
  yield iso_from, iso_to, rate
98
98
  end
@@ -101,6 +101,8 @@ class Money
101
101
 
102
102
  private
103
103
 
104
+ attr_reader :rates, :options, :guard
105
+
104
106
  # Return the rate hashkey for the given currencies.
105
107
  #
106
108
  # @param [String] currency_iso_from The currency to exchange from.
data/lib/money/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Money
2
- VERSION = '6.13.5'
2
+ VERSION = '6.14.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.13.5
4
+ version: 6.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-01 00:00:00.000000000 Z
12
+ date: 2021-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.0.3
162
+ rubygems_version: 3.1.2
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: A Ruby Library for dealing with money and currency conversion.