Module: Exchange

Defined in:
lib/exchange/money.rb,
lib/exchange/iso.rb,
lib/exchange/base.rb,
lib/exchange/helper.rb,
lib/exchange/cache/base.rb,
lib/exchange/cache/file.rb,
lib/exchange/gem_loader.rb,
lib/exchange/cache/rails.rb,
lib/exchange/cache/redis.rb,
lib/exchange/typecasting.rb,
lib/exchange/cache/memory.rb,
lib/exchange/configurable.rb,
lib/exchange/configuration.rb,
lib/exchange/cache/no_cache.rb,
lib/exchange/cache/memcached.rb,
lib/exchange/external_api/ecb.rb,
lib/exchange/external_api/xml.rb,
lib/exchange/external_api/base.rb,
lib/exchange/external_api/call.rb,
lib/exchange/external_api/json.rb,
lib/exchange/cache/configuration.rb,
lib/exchange/external_api/random.rb,
lib/exchange/core_extensions/cachify.rb,
lib/exchange/external_api/xavier_media.rb,
lib/exchange/external_api/configuration.rb,
lib/exchange/core_extensions/float/error_safe.rb,
lib/exchange/external_api/open_exchange_rates.rb,
lib/exchange/core_extensions/numeric/conversability.rb,
lib/exchange/core_extensions/big_decimal/mri_2_1_0_patch.rb

Overview

Top Level Module of the the gem.

Author:

  • Beat Richartz

Since:

  • 0.1

Version:

  • 0.9

Defined Under Namespace

Modules: Cache, Cachify, Conversability, Decachify, ErrorSafe, ExternalAPI, MRI210Patch, Typecasting Classes: Configurable, Configuration, GemLoader, Helper, ISO, Money

Constant Summary collapse

BROKEN_BIG_DECIMAL_DIVISION =

constant for broken big decimal division in MRI 2.1.0 www.ruby-forum.com/topic/4419577

(RUBY_VERSION == '2.1.0' && RUBY_ENGINE == 'ruby')
VERSION =

The current version of the exchange gem

'1.3.0'.freeze
ROOT_PATH =

The root installation path of the gem

Since:

  • 0.1

Version:

  • 0.5

File.dirname(__FILE__).to_s.sub(/\/lib\/exchange\/?$/, '')
Error =

The error superclass for errors within the exchange gem

Since:

  • 1.3

Version:

  • 0.1

Class.new StandardError
UsageError =

The error superclass for usage errors

Since:

  • 1.3

Version:

  • 0.1

Class.new ArgumentError
NoRateError =

The error that gets thrown if no conversion rate is available

Since:

  • 0.1

Version:

  • 0.1

Class.new Error
NoCurrencyError =

The error that gets thrown if the given currency is not a currency

Since:

  • 0.10

Version:

  • 0.10

Class.new UsageError
ImplicitConversionError =

The error that will get thrown when implicit conversions take place and are not allowed

Since:

  • 0.1

Class.new Error

Class Method Summary collapse

Class Method Details

.configurationExchange::Configuration

A getter for the configuration, returns the currently installed configuration or a default configuration if no configuration is installed

Returns:

Since:

  • 0.1



23
24
25
# File 'lib/exchange/configuration.rb', line 23

def configuration
  @configuration ||= Configuration.new
end

.configuration=(configuration) ⇒ Exchange::Configuration

A configuration setter for the Exchange gem. This comes in handy if you want to have backup or test setting

Parameters:

Returns:

Raises:

  • (ArgumentError)

    if fed with anything else than an Exchange::Configuration

Since:

  • 0.1



11
12
13
14
15
16
17
# File 'lib/exchange/configuration.rb', line 11

def configuration= configuration
  if configuration.is_a? Exchange::Configuration
    @configuration = configuration
  else
    raise ArgumentError.new("The configuration needs to be an instance of Exchange::Configuration")
  end
end