Sha256: 231270b3c713bd37713ce5a21b1a1455c0989cf0d67cfcde74cd71e8b97a6d4c

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

module ShopifyApp
  class Configuration

    # Shopify App settings. These values should match the configuration
    # for the app in your Shopify Partners page. Change your settings in
    # `config/initializers/shopify_app.rb`
    attr_accessor :application_name
    attr_accessor :api_key
    attr_accessor :secret
    attr_accessor :scope
    attr_accessor :embedded_app
    alias_method  :embedded_app?, :embedded_app
    attr_accessor :webhooks
    attr_accessor :scripttags
    attr_accessor :after_authenticate_job
    attr_accessor :session_repository

    # customise urls
    attr_accessor :root_url

    # customise ActiveJob queue names
    attr_accessor :scripttags_manager_queue_name
    attr_accessor :webhooks_manager_queue_name

    # configure myshopify domain for local shopify development
    attr_accessor :myshopify_domain

    def initialize
      @root_url = '/'
      @myshopify_domain = 'myshopify.com'
      @scripttags_manager_queue_name = Rails.application.config.active_job.queue_name
      @webhooks_manager_queue_name = Rails.application.config.active_job.queue_name
    end

    def login_url
      File.join(@root_url, 'login')
    end

    def session_repository=(klass)
      if Rails.configuration.cache_classes
        ShopifyApp::SessionRepository.storage = klass
      else
        ActiveSupport::Reloader.to_prepare do
          ShopifyApp::SessionRepository.storage = klass
        end
      end
    end

    def has_webhooks?
      webhooks.present?
    end

    def has_scripttags?
      scripttags.present?
    end
  end

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

  def self.configuration=(config)
    @configuration = config
  end

  def self.configure
    yield configuration
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_app-8.1.0 lib/shopify_app/configuration.rb
shopify_app-8.0.0 lib/shopify_app/configuration.rb