Class: Workarea::Shipping::LocationQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/shipping/location_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(services, country, region) ⇒ LocationQuery

Returns a new instance of LocationQuery.



6
7
8
9
10
# File 'app/models/workarea/shipping/location_query.rb', line 6

def initialize(services, country, region)
  @services = services
  @country = typecast_country(country)
  @region = region
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



4
5
6
# File 'app/models/workarea/shipping/location_query.rb', line 4

def country
  @country
end

#regionObject (readonly)

Returns the value of attribute region.



4
5
6
# File 'app/models/workarea/shipping/location_query.rb', line 4

def region
  @region
end

#servicesObject (readonly)

Returns the value of attribute services.



4
5
6
# File 'app/models/workarea/shipping/location_query.rb', line 4

def services
  @services
end

Instance Method Details

#location_servicesObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/workarea/shipping/location_query.rb', line 12

def location_services
  location_services = matching_services

  if has_service_with_region?
    location_services.select! do |service|
      service.regions.include?(region)
    end
  end

  location_services
end