lib/elasticsearch/model/naming.rb in elasticsearch-model-7.2.1 vs lib/elasticsearch/model/naming.rb in elasticsearch-model-8.0.0.pre

- old
+ new

@@ -15,19 +15,14 @@ # specific language governing permissions and limitations # under the License. module Elasticsearch module Model - - # Provides methods for getting and setting index name and document type for the model + # Provides methods for getting and setting index and name for the model # module Naming - - DEFAULT_DOC_TYPE = '_doc'.freeze - module ClassMethods - # Get or set the name of the index # # @example Set the index name for the `Article` model # # class Article @@ -62,50 +57,22 @@ # @see index_name def index_name=(name) @index_name = name end - # Get or set the document type - # - # @example Set the document type for the `Article` model - # - # class Article - # document_type "my-article" - # end - # - # @example Directly set the document type for the `Article` model - # - # Article.document_type "my-article" - # - def document_type name=nil - @document_type = name || @document_type || implicit(:document_type) - end + private - - # Set the document type - # - # @see document_type - # - def document_type=(name) - @document_type = name + def implicit(prop) + self.send("default_#{prop}") end - private - - def implicit(prop) - self.send("default_#{prop}") - end - - def default_index_name - self.model_name.collection.gsub(/\//, '-') - end - - def default_document_type; end + def default_index_name + self.model_name.collection.gsub(/\//, '-') + end end module InstanceMethods - # Get or set the index name for the model instance # # @example Set the index name for an instance of the `Article` model # # @article.index_name "articles-#{@article.user_id}" @@ -127,27 +94,9 @@ # # @see index_name def index_name=(name) @index_name = name end - - # @example Set the document type for an instance of the `Article` model - # - # @article.document_type "my-article" - # @article.__elasticsearch__.update_document - # - def document_type name=nil - @document_type = name || @document_type || self.class.document_type - end - - # Set the document type - # - # @see document_type - # - def document_type=(name) - @document_type = name - end end - end end end