Module: Elasticsearch::Model::Client::InstanceMethods

Included in:
Proxy::InstanceMethodsProxy
Defined in:
lib/elasticsearch/model/client.rb

Instance Method Summary collapse

Instance Method Details

#clientObject

Get or set the client for a specific model instance

Examples:

Get the client for a specific record and perform API request

 @article = Article.first @article.client.info # => { "name" => "Node-1", ... }
 56 57 58
# File 'lib/elasticsearch/model/client.rb', line 56 def client @client ||= self.class.client end

#client=(client) ⇒ Object

Set the client for a specific model instance

Examples:

Set the client for a specific record

 @article = Article.first @article.client = Elasticsearch::Client.new host: 'http://api.server:8080'
 67 68 69
# File 'lib/elasticsearch/model/client.rb', line 67 def client=(client) @client = client end