Class: SpreeCmCommissioner::AppleAppSiteAssociationFetcher

Inherits:
BaseInteractor
  • Object
show all
Defined in:
app/interactors/spree_cm_commissioner/apple_app_site_association_fetcher.rb

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



18
19
20
21
# File 'app/interactors/spree_cm_commissioner/apple_app_site_association_fetcher.rb', line 18

def cache_key
  updated_at = tenant&.updated_at || store&.updated_at
  "well_known:apple-app-site-association:#{resource.class.name}:#{resource.id}:#{updated_at}"
end

#callObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/interactors/spree_cm_commissioner/apple_app_site_association_fetcher.rb', line 5

def call
  key = cache_key

  CmAppLogger.log(label: 'LOOKING_UP_CACHE', data: { cache_key: key })

  Rails.cache.delete(key) if refreshed

  context.contents = Rails.cache.fetch(key) do
    CmAppLogger.log(label: 'CACHE_MISS', data: { cache_key: key })
    resource.preferred_apple_app_site_association
  end
end

#resourceObject



23
24
25
# File 'app/interactors/spree_cm_commissioner/apple_app_site_association_fetcher.rb', line 23

def resource
  tenant || store
end