Module: Elasticsearch::Persistence::ClassMethods

Included in:
Elasticsearch::Persistence
Defined in:
lib/elasticsearch/persistence.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#client(client = nil) ⇒ Object

Get or set the default client for all repositories and models

Examples:

Set and configure the default client


Elasticsearch::Persistence.client Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true

Perform an API request through the client


Elasticsearch::Persistence.client.cluster.health
# => { "cluster_name" => "elasticsearch" ... }


94
95
96
# File 'lib/elasticsearch/persistence.rb', line 94

def client client=nil
  @client = client || @client || Elasticsearch::Client.new
end

#client=(client) ⇒ Object

Set the default client for all repositories and models

Examples:

Set and configure the default client


Elasticsearch::Persistence.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
=> #<Elasticsearch::Transport::Client:0x007f96a6dd0d80 @transport=... >


105
106
107
# File 'lib/elasticsearch/persistence.rb', line 105

def client=(client)
  @client = client
end