Class: ModernTreasury::PaymentMethod

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

Overview

When opening an invoice, whether to show the embedded payment UI , automatically debit the recipient, or rely on manual payment from the recipient.

Constant Summary collapse

PAYMENT_METHOD =
[
  # TODO: Write general description for UI
  UI = 'ui'.freeze,

  # TODO: Write general description for MANUAL
  MANUAL = 'manual'.freeze,

  # TODO: Write general description for AUTOMATIC
  AUTOMATIC = 'automatic'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = UI) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/modern_treasury/models/payment_method.rb', line 28

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

  str = value.to_s.strip

  case str.downcase
  when 'ui' then UI
  when 'manual' then MANUAL
  when 'automatic' then AUTOMATIC
  else
    default_value
  end
end

.validate(value) ⇒ Object



22
23
24
25
26
# File 'lib/modern_treasury/models/payment_method.rb', line 22

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

  PAYMENT_METHOD.include?(value)
end