Module: Spree::IntegrationBackedProvider

Extended by:
ActiveSupport::Concern
Included in:
DeliveryRateProvider::Base, FulfillmentProvider::Base, Spree::InventoryProvider::Base, PricingProvider::Base
Defined in:
app/models/concerns/spree/integration_backed_provider.rb

Overview

Shared contract for provider classes whose credentials live on a Integration: delivery rates, fulfillment, pricing and inventory.

A provider declares only integration_class; whether a store may use it, how it is labelled in the admin, and how its credentials are resolved all follow from that. Stating those three rules once means a change to what "connected" means — an expired OAuth grant, say — lands in one place rather than in each provider family.

Instance Method Summary collapse

Instance Method Details

#integration_for(store) ⇒ Spree::Integration?

The connected, active integration carrying this provider's credentials. Request-cached via Current.integrations, so a provider asking per catalog row costs one query per request, not one per row.

Parameters:

Returns:



83
84
85
86
87
# File 'app/models/concerns/spree/integration_backed_provider.rb', line 83

def integration_for(store)
  return if self.class.integration_class.blank?

  self.class.active_integrations(store).find { |integration| integration.type == self.class.integration_class }
end