module Elasticsearch::Rails2::Naming::InstanceMethods

Public Instance Methods

document_type(name=nil) click to toggle source

Get or set the document type

@example Set the document type for an instance of the ‘Building` model

@bulding.document_type "my-building"
# File lib/elasticsearch/rails2/naming.rb, line 109
def document_type name=nil
  @document_type = name || @document_type || self.class.document_type
end
document_type=(name) click to toggle source

Set the document type

@see document_type

# File lib/elasticsearch/rails2/naming.rb, line 118
def document_type=(name)
  @document_type = name
end
index_name(name=nil, &block) click to toggle source

Get or set the index name for the model instance

@example Set the index name for an instance of the ‘Building` model

@building.index_name "buildings-#{@building.sourceid}"
# File lib/elasticsearch/rails2/naming.rb, line 83
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) click to toggle source

Set the index name

@see index_name

# File lib/elasticsearch/rails2/naming.rb, line 98
def index_name=(name)
  @index_name = name
end