Class: ModernTreasury::Type12

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

Overview

Indicates whether the line item is ‘originating` or `receiving` (see www.moderntreasury.com/journal/beginners-guide-to-ach for more).

Constant Summary collapse

TYPE12 =
[
  # TODO: Write general description for ORIGINATING
  ORIGINATING = 'originating'.freeze,

  # TODO: Write general description for RECEIVING
  RECEIVING = 'receiving'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ORIGINATING) ⇒ Object



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

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

  str = value.to_s.strip

  case str.downcase
  when 'originating' then ORIGINATING
  when 'receiving' then RECEIVING
  else
    default_value
  end
end

.validate(value) ⇒ Object



18
19
20
21
22
# File 'lib/modern_treasury/models/type12.rb', line 18

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

  TYPE12.include?(value)
end