module Elasticsearch::Persistence::Client::ClassMethods
Public Instance Methods
client(client=nil)
click to toggle source
Get or set the default client for this repository
@example Set and configure the client for the repository class
class MyRepository include Elasticsearch::Persistence::Repository client Elasticsearch::Client.new host: 'http://localhost:9200', log: true end
@example Set and configure the client for this repository instance
repository.client Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
@example Perform an API request through the client
MyRepository.client.cluster.health repository.client.cluster.health # => { "cluster_name" => "elasticsearch" ... }
# File lib/elasticsearch/persistence/client.rb, line 30 def client client=nil @client = client || @client || Elasticsearch::Persistence.client end
client=(client)
click to toggle source
Set the default client for this repository
@example Set and configure the client for the repository class
MyRepository.client = Elasticsearch::Client.new host: 'http://localhost:9200', log: true
@example Set and configure the client for this repository instance
repository.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
# File lib/elasticsearch/persistence/client.rb, line 44 def client=(client) @client = client end