forked from elastic/elasticsearch-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaming.rb
35 lines (28 loc) · 842 Bytes
/
naming.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Elasticsearch
module Model
module Naming
module ClassMethods
# Get or set the name of the index
#
# TODO: Dynamic names a la Tire -- `Article.index_name { "articles-#{Time.now.year}" }`
#
def index_name name=nil
@index_name = name || @index_name || self.model_name.collection
end
# Get or set the document type
#
def document_type name=nil
@document_type = name || @document_type || self.model_name.element
end
end
module InstanceMethods
def index_name name=nil
@index_name = name || @index_name || self.class.index_name
end
def document_type name=nil
@document_type = name || @document_type || self.class.document_type
end
end
end
end
end