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

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

Instance Method Summary collapse

Instance Method Details

#document_type(name = nil) ⇒ Object

Examples:

Set the document type for an instance of the ‘Article` model


@article.document_type "my-article"
@article.__elasticsearch__.update_document


138
139
140
# File 'lib/elasticsearch/model/naming.rb', line 138

def document_type name=nil
  @document_type = name || @document_type || self.class.document_type
end

#document_type=(name) ⇒ Object

Set the document type

See Also:



146
147
148
# File 'lib/elasticsearch/model/naming.rb', line 146

def document_type=(name)
  @document_type = name
end

#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


114
115
116
117
118
119
120
121
122
123
124
# File 'lib/elasticsearch/model/naming.rb', line 114

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:



129
130
131
# File 'lib/elasticsearch/model/naming.rb', line 129

def index_name=(name)
  @index_name = name
end