elasticsearch-model/lib/elasticsearch/model/naming.rb
# Get or set the name of the index
#
# @example Set the index name for the `Article` model
#
#     class Article
#       index_name "articles-#{Rails.env}"
#     end
#
# @example Set the index name for the `Article` model and re-evaluate it on each call
#
#     class Article
#       index_name { "articles-#{Time.now.year}" }
#     end
#
# @example Directly set the index name for the `Article` model
#
#     Article.index_name "articles-#{Rails.env}"
#
#
Get or set the name of the index
Get or set the name of the index
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.model_name.collection.gsub(/\//, '-')
          end
        end
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 . model_name . collection . gsub ( / \/ / , '-' ) end end
Get or set the name of the index
Get or set the name of the index
name
<not_specific>
block
<not_specific>
example
Set the index name for the `Article` model class Article index_name "articles-#{Rails.env}" end
Set the index name for the ` Article ` model class Article index_name " articles - # { Rails . env } " end
example
Set the index name for the `Article` model and re-evaluate it on each call class Article index_name { "articles-#{Time.now.year}" } end
Set the index name for the ` Article ` model and re - evaluate it on each call class Article index_name { " articles - # { Time . now . year } " } end
example
Directly set the index name for the `Article` model Article.index_name "articles-#{Rails.env}"
Directly set the index name for the ` Article ` model Article . index_name " articles - # { Rails . env } "