Class: LoyaltyApIs::ProductType

Inherits:
Object
  • Object
show all
Defined in:
lib/loyalty_ap_is/models/product_type.rb

Overview

Indicating the Type of the product (Fuel, CR, CC, PARTNER, OTHER, GREEN_ENERGY).

Constant Summary collapse

PRODUCT_TYPE =
[
  # TODO: Write general description for FUEL
  FUEL = 'FUEL'.freeze,

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

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

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

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

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FUEL) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/loyalty_ap_is/models/product_type.rb', line 36

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

  str = value.to_s.strip

  case str.downcase
  when 'fuel' then FUEL
  when 'cr' then CR
  when 'cc' then CC
  when 'partner' then PARTNER
  when 'other' then OTHER
  when 'green_energy' then GREEN_ENERGY
  else
    default_value
  end
end

.validate(value) ⇒ Object



30
31
32
33
34
# File 'lib/loyalty_ap_is/models/product_type.rb', line 30

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

  PRODUCT_TYPE.include?(value)
end