Skip to content
Browse files

[DOC] Added documentation for the Model::Naming module

  • Loading branch information...
1 parent c6e43a3 commit ea3da8c3b0bbe14db144f3de59ca86ec86f64933 @karmi karmi committed Sep 4, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/tire/model/naming.rb
View
20 lib/tire/model/naming.rb
@@ -1,24 +1,44 @@
module Tire
module Model
+ # Contains logic for getting and setting the index name and document type for this model.
+ #
module Naming
module ClassMethods
+
+ # Get or set the index name for this model, based on arguments.
+ #
+ # To get the index name:
+ #
+ # Article.index_name
+ #
+ # To set the index name:
+ #
+ # Article.index_name 'my-custom-name'
+ #
def index_name name=nil
@index_name = name if name
@index_name || klass.model_name.plural
end
+ # Get the document type for this model, based on the class name.
+ #
def document_type
klass.model_name.singular
end
end
module InstanceMethods
+
+ # Proxy to class method `index_name`.
+ #
def index_name
instance.class.tire.index_name
end
+ # Proxy to instance method `document_type`.
+ #
def document_type
instance.class.tire.document_type
end

0 comments on commit ea3da8c

Please sign in to comment.
Something went wrong with that request. Please try again.