Sha256: 2945dde115bb94cd523426c9355805876c00c26ff1960948905be271d81d54c4

Contents?: true

Size: 882 Bytes

Versions: 2

Compression:

Stored size: 882 Bytes

Contents

module AlgoliaSearch
  module Configuration
    def initiliaze
      @client = nil
    end

    def configuration
      @@configuration || raise(NotConfigured, "Please configure AlgoliaSearch. Set AlgoliaSearch.configuration = {application_id: 'YOUR_APPLICATION_ID', api_key: 'YOUR_API_KEY'}")
    end

    def configuration=(configuration)
      @@configuration = configuration.merge(
        :user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Rails (#{Rails::VERSION::STRING})",
        :symbolize_keys => false
      )
    end

    def client_opts
      @@opts ||= {}
    end

    def client_opts=(opts)
      @@opts = opts
    end

    def client
      if @client.nil?
        setup_client
      end

      @client
    end

    def setup_client
      @client = Algolia::Search::Client.new(Algolia::Search::Config.new(@@configuration), client_opts)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
algoliasearch-rails-2.2.1 lib/algoliasearch/configuration.rb
algoliasearch-rails-2.2.0 lib/algoliasearch/configuration.rb