Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/money/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class UnknownCurrency < ArgumentError; end

class << self
def new(currency_iso)
raise UnknownCurrency, "Currency can't be blank" if currency_iso.nil? || currency_iso.to_s.empty?
iso = currency_iso.to_s.downcase
@@loaded_currencies[iso] || @@mutex.synchronize { @@loaded_currencies[iso] = super(iso) }
iso = currency_iso.to_s
return @@loaded_currencies[iso] if @@loaded_currencies.key?(iso)
raise UnknownCurrency, "Currency can't be blank" if iso.empty?
downcased = iso.downcase
@@mutex.synchronize do
@@loaded_currencies[iso] ||= @@loaded_currencies[downcased] ||= super(downcased)
end
end
alias_method :find!, :new

Expand Down
Loading