Class: DeliveryChannel::DistanceCalculator

Inherits:
Object
  • Object
show all
Includes:
DefaultErrorContainer
Defined in:
app/my_lib/delivery_channel/distance_calculator.rb

Overview

typed: ignore

Defined Under Namespace

Classes: NoRouteFound

Instance Method Summary collapse

Methods included from DefaultErrorContainer

#error, #error_message_simple, #merge_errors

Constructor Details

#initialize(provider = nil, country = 'TH') ⇒ DistanceCalculator

Returns a new instance of DistanceCalculator.



5
6
7
8
# File 'app/my_lib/delivery_channel/distance_calculator.rb', line 5

def initialize(provider = nil, country = 'TH')
  @provider = provider.presence || AdminSetting.distance_calculator_provider
  @country = country
end

Instance Method Details

#find_distance_to_restaurant(destination, restaurant, custom_provider = nil) ⇒ Object



10
11
12
13
# File 'app/my_lib/delivery_channel/distance_calculator.rb', line 10

def find_distance_to_restaurant(destination, restaurant, custom_provider = nil)
  custom_provider = custom_provider.nil? ? provider : custom_provider
  send "find_distance_to_restaurant_using_#{custom_provider}", destination, restaurant
end