RubyMoney/money · error · NotImplementedError

#exchange_with must be implemented

Error message

#exchange_with must be implemented

What it means

Error "#exchange_with must be implemented" thrown in RubyMoney/money.

Source

Thrown at lib/money/bank/base.rb:102

      # +to_currency+.
      #
      # @abstract Subclass and override +#exchange_with+ to implement a custom
      #  +Money::Bank+ class.
      #
      # @raise NotImplementedError
      #
      # @param [Money] from The +Money+ object to exchange from.
      # @param [Money::Currency, String, Symbol] to_currency The currency
      #  string or object to exchange to.
      # @yield [n] Optional block to use to round the result after making
      #  the exchange.
      # @yieldparam [Float] n The result after exchanging from one currency to
      #  the other.
      # @yieldreturn [Integer]
      #
      # @return [Money]
      def exchange_with(from, to_currency, &)
        raise NotImplementedError, "#exchange_with must be implemented"
      end

      # Given two currency strings or object, checks whether they're both the
      # same currency. Return +true+ if the currencies are the same, +false+
      # otherwise.
      #
      # @param [Money::Currency, String, Symbol] currency1 The first currency
      #  to compare.
      # @param [Money::Currency, String, Symbol] currency2 The second currency
      #  to compare.
      #
      # @return [Boolean]
      #
      # @example
      #   same_currency?("usd", "USD")                #=> true
      #   same_currency?("usd", "EUR")                #=> false
      #   same_currency?("usd", Currency.new("USD"))   #=> true
      #   same_currency?("usd", "USD")                #=> true

View on GitHub (pinned to 26e2829c34)

When it happens

Trigger: Thrown at lib/money/bank/base.rb:102 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of RubyMoney/money@26e2829c34 (2026-08-23). Data as JSON: /api/errors/ebe0d30adfbd9927. Report an issue: GitHub.