Class: AdvancedBilling::TaxDestinationAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/advanced_billing/models/tax_destination_address.rb

Overview

Tax Destination Address.

Constant Summary collapse

TAX_DESTINATION_ADDRESS =
[
  # TODO: Write general description for SHIPPING_THEN_BILLING
  SHIPPING_THEN_BILLING = 'shipping_then_billing'.freeze,

  # TODO: Write general description for BILLING_THEN_SHIPPING
  BILLING_THEN_SHIPPING = 'billing_then_shipping'.freeze,

  # TODO: Write general description for SHIPPING_ONLY
  SHIPPING_ONLY = 'shipping_only'.freeze,

  # TODO: Write general description for BILLING_ONLY
  BILLING_ONLY = 'billing_only'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SHIPPING_THEN_BILLING) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/tax_destination_address.rb', line 29

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

  str = value.to_s.strip

  case str.downcase
  when 'shipping_then_billing' then SHIPPING_THEN_BILLING
  when 'billing_then_shipping' then BILLING_THEN_SHIPPING
  when 'shipping_only' then SHIPPING_ONLY
  when 'billing_only' then BILLING_ONLY
  else
    default_value
  end
end

.validate(value) ⇒ Object



23
24
25
26
27
# File 'lib/advanced_billing/models/tax_destination_address.rb', line 23

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

  TAX_DESTINATION_ADDRESS.include?(value)
end