Skalar / google_distance_matrix

Ruby client for The Google Distance Matrix API.
MIT License
57 stars 45 forks source link

"Wrong number of arguments" when using the cache #53

Closed brianlow closed 3 years ago

brianlow commented 3 years ago

When caching is configured, we see this error

ArgumentError: wrong number of arguments (given 2, expected 1)

To reproduce:

GoogleDistanceMatrix.configure_defaults do |config|
  config.cache = ActiveSupport::Cache.lookup_store :redis_cache_store, {
    expires_in: 1.hour
  }
end

from_place = GoogleDistanceMatrix::Place.new(lat: 37.762282, lng: -122.4363949)
to_place = GoogleDistanceMatrix::Place.new(lat: 37.63981, lng: -122.415728)

matrix = GoogleDistanceMatrix::Matrix.new
matrix.configure { |c| c.google_api_key = '...' }
matrix.origins.push(from_place, to_place)
matrix.origins.push(from_place, to_place)
matrix.destinations.push(from_place, to_place)

outbound = matrix.route_for origin: from_place, destination: to_place_place

ArgumentError: wrong number of arguments (given 2, expected 1)
from /Users/brian/.asdf/installs/ruby/3.0.1/lib/ruby/gems/3.0.0/gems/google_distance_matrix-0.6.3/lib/google_distance_matrix/client.rb:23:in `get'

google_distance_matrix (0.6.3)

I think the problem is client_cache is calling client but passing a hash when it expects keyword arguments

thhermansen commented 3 years ago

I included your fix in version 0.6.4 🎉