module Elasticsearch::Rails2::Naming::ClassMethods
Public Instance Methods
document_type(name=nil)
click to toggle source
Get or set the document type
@example Set the document type for the ‘Building` model
class Building document_type "my-building" end
@example Directly set the document type for the ‘Building` model
Building.document_type "my-building"
# File lib/elasticsearch/rails2/naming.rb, line 60 def document_type name=nil @document_type = name || @document_type || self.model_name.collection end
document_type=(name)
click to toggle source
Set the document type
@see document_type
# File lib/elasticsearch/rails2/naming.rb, line 69 def document_type=(name) @document_type = name end
index_name(name=nil, &block)
click to toggle source
Get or set the name of the index
@example Set the index name for the ‘Building` model
class Building index_name "buildings-#{Rails.env}" end
@example Set the index name for the ‘Building` model and re-evaluate it on each call
class Building index_name { "buildings-#{Time.now.year}" } end
@example Directly set the index name for the ‘Building` model
Building.index_name "buildings-#{Rails.env}"
# File lib/elasticsearch/rails2/naming.rb, line 29 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 || Elasticsearch::Rails2.index_name || "#{self.model_name.collection}_index" end end
index_name=(name)
click to toggle source
Set the index name
@see index_name
# File lib/elasticsearch/rails2/naming.rb, line 44 def index_name=(name) @index_name = name end