Sha256: 3c0acca07721f9fc8ba452e74235f36f438be451d7c64a0490e6feb21c46dffd

Contents?: true

Size: 779 Bytes

Versions: 4

Compression:

Stored size: 779 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
      if @client.nil?
        setup_client
      end

      @client
    end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
yc-algoliasearch-rails-2.1.4 lib/algoliasearch/configuration.rb
algoliasearch-rails-2.1.4 lib/algoliasearch/configuration.rb
algoliasearch-rails-2.1.3 lib/algoliasearch/configuration.rb
algoliasearch-rails-2.1.2 lib/algoliasearch/configuration.rb