Class: ModernTreasury::ReceivingAccountType

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

Overview

ReceivingAccountType.

Constant Summary collapse

RECEIVING_ACCOUNT_TYPE =
[
  # TODO: Write general description for INTERNAL_ACCOUNT
  INTERNAL_ACCOUNT = 'internal_account'.freeze,

  # TODO: Write general description for EXTERNAL_ACCOUNT
  EXTERNAL_ACCOUNT = 'external_account'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = INTERNAL_ACCOUNT) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/modern_treasury/models/receiving_account_type.rb', line 23

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

  str = value.to_s.strip

  case str.downcase
  when 'internal_account' then INTERNAL_ACCOUNT
  when 'external_account' then EXTERNAL_ACCOUNT
  else
    default_value
  end
end

.validate(value) ⇒ Object



17
18
19
20
21
# File 'lib/modern_treasury/models/receiving_account_type.rb', line 17

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

  RECEIVING_ACCOUNT_TYPE.include?(value)
end