Class: Dhl::Bcs::V2::Locator

Inherits:
Object
  • Object
show all
Defined in:
lib/dhl/bcs/v2/locator.rb

Overview

finds proper class from attributes and builds object

Class Method Summary collapse

Class Method Details

.for(attributes = {}) ⇒ Object



5
6
7
8
# File 'lib/dhl/bcs/v2/locator.rb', line 5

def self.for(attributes = {})
  location_class = location_class_finder(attributes)
  location_builder(attributes, location_class: location_class)
end

.location_builder(attributes = {}, location_class: Address) ⇒ Object



22
23
24
# File 'lib/dhl/bcs/v2/locator.rb', line 22

def self.location_builder(attributes = {}, location_class: Address)
  location_class.build(attributes)
end

.location_class_finder(attributes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dhl/bcs/v2/locator.rb', line 10

def self.location_class_finder(attributes)
  if attributes.key?(:packstation_number)
    Packstation
  elsif attributes.key?(:postfilial_number)
    Postfiliale
  elsif attributes.key?(:parcel_shop_number)
    ParcelShop
  else
    Address
  end
end