Class: ModernTreasury::ForeignExchangeIndicator

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/models/foreign_exchange_indicator.rb

Overview

Indicates the type of FX transfer to initiate, can be either ‘variable_to_fixed`, `fixed_to_variable`, or `null` if the payment order currency matches the originating account currency.

Constant Summary collapse

FOREIGN_EXCHANGE_INDICATOR =
[
  # TODO: Write general description for FIXED_TO_VARIABLE
  FIXED_TO_VARIABLE = 'fixed_to_variable'.freeze,

  # TODO: Write general description for VARIABLE_TO_FIXED
  VARIABLE_TO_FIXED = 'variable_to_fixed'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FIXED_TO_VARIABLE) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/modern_treasury/models/foreign_exchange_indicator.rb', line 25

def self.from_value(value, default_value = FIXED_TO_VARIABLE)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'fixed_to_variable' then FIXED_TO_VARIABLE
  when 'variable_to_fixed' then VARIABLE_TO_FIXED
  else
    default_value
  end
end

.validate(value) ⇒ Object



19
20
21
22
23
# File 'lib/modern_treasury/models/foreign_exchange_indicator.rb', line 19

def self.validate(value)
  return false if value.nil?

  FOREIGN_EXCHANGE_INDICATOR.include?(value)
end