Sha256: d95887bbe1db2752650d227fbcd1ab92b7f7fa504778c3c900ab449fdd0bcb05

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module SolidusAfterpay
  class Configuration
    attr_accessor :use_solidus_api
    attr_writer :shipping_rate_builder_service_class, :cache_expiry

    def dummy_email
      'afterpay@dummy.com'
    end

    def shipping_rate_builder_service_class
      @shipping_rate_builder_service_class ||= 'SolidusAfterpay::ShippingRateBuilderService'
      @shipping_rate_builder_service_class.constantize
    end

    def update_order_attributes_service_class
      @update_order_attributes_service_class ||= 'SolidusAfterpay::UpdateOrderAttributesService'
      @update_order_attributes_service_class.constantize
    end

    def cache_expiry
      @cache_expiry ||= 1.day
    end
  end

  class << self
    def configuration
      @configuration ||= Configuration.new
    end

    alias config configuration

    def configure
      yield configuration
    end

    def api_base_controller_parent_class
      return ::Spree::Api::BaseController if configuration.use_solidus_api

      SolidusAfterpay::BaseController
    end

    delegate :shipping_rate_builder_service_class, to: :configuration
    delegate :update_order_attributes_service_class, to: :configuration
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_afterpay-0.2.0 lib/solidus_afterpay/configuration.rb