Permalink
Browse files

Handle to currency as string or Currency when getting rate.

  • Loading branch information...
1 parent 984c6ee commit e742a0ce95fcc318e845274776b718ac6a3590cb @chris chris committed Apr 11, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/database_bank/database_exchange.rb
@@ -8,10 +8,10 @@ class DatabaseExchange < Money::Bank::VariableExchange
# Retrieve the rate for the given currencies
#
# from_currency - a Currency object representing the currency being converted from
- # to_iso_code - the ISO code of the currency to convert to
+ # to_currency - a Currency or String with the ISO code of the currency to convert to
#
- def get_rate(from_currency, to_iso_code)
- rate = DatabaseBank.exchange_rate_model.where(from_currency: from_currency.iso_code).where(to_currency: to_iso_code).order(:sourced_at).last
+ def get_rate(from_currency, to_currency)
+ rate = DatabaseBank.exchange_rate_model.where(from_currency: from_currency.iso_code).where(to_currency: to_currency.to_s).order(:sourced_at).last
raise UnknownRate unless rate
rate.rate
end

0 comments on commit e742a0c

Please sign in to comment.