es-elasticity 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/elasticity/document.rb +13 -9
- data/lib/elasticity/version.rb +1 -1
- data/spec/units/document_spec.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 858cb2be175394c54d6764ee32e64e467c82ae42
|
4
|
+
data.tar.gz: a78140e39c9a3eba158aa9c8196622de078206e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b76a96bc437e1a3015c3e2cde9ce3eb41777163cd572ae23fac8a344234e0d6d4f7e4d545b44e177d5ac8a11a15e90236f6fe8d87f3ebdc37a5484b31c7a07b
|
7
|
+
data.tar.gz: d4fc42b3ca6f553ceeb4a761cb7a89146a008bafbadfcbb9076c6622ff59d39f8a135e751c93e8509628f8dd3bd4c1411208a029a7b546b1c0f0c7406ff095ac
|
data/lib/elasticity/document.rb
CHANGED
@@ -5,7 +5,7 @@ module Elasticity
|
|
5
5
|
# Returns the instance of Elasticity::Index associated with this document.
|
6
6
|
def self.index
|
7
7
|
return @index if @index.present?
|
8
|
-
@index = Index.new(Elasticity.config.client, self.
|
8
|
+
@index = Index.new(Elasticity.config.client, self.namespaced_index_name)
|
9
9
|
end
|
10
10
|
|
11
11
|
# Creates the index for this document
|
@@ -22,20 +22,24 @@ module Elasticity
|
|
22
22
|
# By default, it's the class name converted to underscore and plural.
|
23
23
|
def self.index_name
|
24
24
|
return @index_name if defined?(@index_name)
|
25
|
-
|
26
25
|
@index_name = self.name.underscore.pluralize
|
27
|
-
|
28
|
-
if namespace = Elasticity.config.namespace
|
29
|
-
@index_name = "#{namespace}_#{index_name}"
|
30
|
-
end
|
31
|
-
|
32
|
-
@index_name
|
33
26
|
end
|
34
27
|
|
35
28
|
# Sets the index name to something else than the default
|
36
29
|
def self.index_name=(name)
|
37
30
|
@index_name = name
|
38
|
-
@index
|
31
|
+
@index = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Namespaced index name
|
35
|
+
def self.namespaced_index_name
|
36
|
+
name = self.index_name
|
37
|
+
|
38
|
+
if namespace = Elasticity.config.namespace
|
39
|
+
name = "#{namespace}_#{name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
name
|
39
43
|
end
|
40
44
|
|
41
45
|
# The document type to be used, it's inferred by the class name.
|
data/lib/elasticity/version.rb
CHANGED
data/spec/units/document_spec.rb
CHANGED
@@ -48,8 +48,10 @@ RSpec.describe Elasticity::Document do
|
|
48
48
|
subject { klass }
|
49
49
|
|
50
50
|
it "extracts index name and document type from the class name" do
|
51
|
-
expect(subject.index_name).to eq "
|
51
|
+
expect(subject.index_name).to eq "class_names"
|
52
|
+
expect(subject.namespaced_index_name).to eq "elasticity_test_class_names"
|
52
53
|
expect(subject.document_type).to eq "class_name"
|
54
|
+
expect(subject.index.name).to eq "elasticity_test_class_names"
|
53
55
|
end
|
54
56
|
|
55
57
|
it "have an associated Index instance" do
|