alexreisner/geocoder

Setting cache_options expiration without prefix causes prefix to default to nil instead of "geocoder:"

corwinstephen opened this issue · 3 comments

Expected behavior

With:

Geocoder.configure(
  cache_options: {
    expiration: 1.days },
)
Geocoder.config[:cache_options][:prefix]

should be geocoder:

Actual behavior

Geocoder.config[:cache_options][:prefix]

is nil

Steps to reproduce

Use

Geocoder.configure(
  cache_options: {
    expiration: 1.days },
)

as your config. Then call Geocoder.config[:cache_options][:prefix]

Environment info

  • Geocoder version: 1.8.0
  • Rails version: 6.1.3.2
  • Database (if applicable):
  • Lookup (if applicable):

Thanks for this, and sorry for the delay. I agree that this behavior is unexpected. The hash should probably be merged into cache_options, instead of replacing it. I'm open to a PR for this.

Hmm, I just realized there's a conflict here. Currently, when passing a hash to Geocoder.configure to set options for a particular service (eg: Geocoder.configure(esri: {token: '...', for_storage: true})), the behavior is to overwrite, not merge. So changing to merge could break apps and therefore requires a minor version release.

Sounds good to me--thanks for taking a look!