Class: Verizon::DistributionTypes

Inherits:
Object
  • Object
show all
Defined in:
lib/verizon/models/distribution_types.rb

Overview

The distribution types: - Targeted: Generate targeted messages to the road users that are affected by the zone rules - Broadcast: Broadcast messages to regions based on the Geofence.

Constant Summary collapse

DISTRIBUTION_TYPES =
[
  # TODO: Write general description for TARGETED
  TARGETED = 'Targeted'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = TARGETED) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/verizon/models/distribution_types.rb', line 25

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

  str = value.to_s.strip

  case str.downcase
  when 'targeted' then TARGETED
  when 'broadcast' then BROADCAST
  else
    default_value
  end
end

.validate(value) ⇒ Object



19
20
21
22
23
# File 'lib/verizon/models/distribution_types.rb', line 19

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

  DISTRIBUTION_TYPES.include?(value)
end