Module: Elasticsearch::Model::Naming::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#index_name(name = nil, &block) ⇒ Object

Get or set the index name for the model instance

Examples:

Set the index name for an instance of the ‘Article` model


@article.index_name "articles-#{@article.user_id}"
@article.__elasticsearch__.update_document


81
82
83
84
85
86
87
88
89
90
91
# File 'lib/elasticsearch/model/naming.rb', line 81

def index_name name=nil, &block
  if name || block_given?
    return (@index_name = name || block)
  end

  if @index_name.respond_to?(:call)
    @index_name.call
  else
    @index_name || self.class.index_name
  end
end

#index_name=(name) ⇒ Object

Set the index name

See Also:



96
97
98
# File 'lib/elasticsearch/model/naming.rb', line 96

def index_name=(name)
  @index_name = name
end