Skip to content

Commit

Permalink
Handle to currency as string or Currency when getting rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Bailey committed Apr 11, 2012
1 parent 984c6ee commit e742a0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/database_bank/database_exchange.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class DatabaseExchange < Money::Bank::VariableExchange
# Retrieve the rate for the given currencies # Retrieve the rate for the given currencies
# #
# from_currency - a Currency object representing the currency being converted from # 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) def get_rate(from_currency, to_currency)
rate = DatabaseBank.exchange_rate_model.where(from_currency: from_currency.iso_code).where(to_currency: to_iso_code).order(:sourced_at).last 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 raise UnknownRate unless rate
rate.rate rate.rate
end end
Expand Down

0 comments on commit e742a0c

Please sign in to comment.