Class: Location::Services::StubbedService

Inherits:
Object
  • Object
show all
Defined in:
lib/location/services/stubbed_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attributesObject



4
5
6
# File 'lib/location/services/stubbed_service.rb', line 4

def self.attributes
  @attributes ||= {}
end

.attributes_for(postal_code) ⇒ Object



12
13
14
# File 'lib/location/services/stubbed_service.rb', line 12

def self.attributes_for(postal_code)
  self.attributes[postal_code] || {}
end

.set_result(postal_code, attributes) ⇒ Object



8
9
10
# File 'lib/location/services/stubbed_service.rb', line 8

def self.set_result(postal_code, attributes)
  self.attributes[postal_code] ||= attributes
end

Instance Method Details

#fetch(postal_code, address) ⇒ Object



16
17
18
19
20
# File 'lib/location/services/stubbed_service.rb', line 16

def fetch(postal_code, address)
  self.class.attributes_for(postal_code).each do |k, v|
    address.send("#{k}=", v)
  end
end