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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eae89b7a0a9c5a5e4d366629cea6f69c64dda6cb
4
- data.tar.gz: d0909b0bee1cf553d07f5b4cd15fccb650079bc9
3
+ metadata.gz: 858cb2be175394c54d6764ee32e64e467c82ae42
4
+ data.tar.gz: a78140e39c9a3eba158aa9c8196622de078206e5
5
5
  SHA512:
6
- metadata.gz: 35ff37389ad9488068bff0dccb08c17976bb06abb36255a16a0e66e17451b0505c1de11926288e9f09cef8a98c870b6e52e5ae8ac3412dba01660bb2ce03b65e
7
- data.tar.gz: 2facdd354cecbfd440536992f072526003277b9ed5039cbec11ebee722554c7e4af73291eaa336eb21d80304e4716dfed6869db4053d64c3d426fe763133c4c1
6
+ metadata.gz: 3b76a96bc437e1a3015c3e2cde9ce3eb41777163cd572ae23fac8a344234e0d6d4f7e4d545b44e177d5ac8a11a15e90236f6fe8d87f3ebdc37a5484b31c7a07b
7
+ data.tar.gz: d4fc42b3ca6f553ceeb4a761cb7a89146a008bafbadfcbb9076c6622ff59d39f8a135e751c93e8509628f8dd3bd4c1411208a029a7b546b1c0f0c7406ff095ac
@@ -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.index_name)
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 = nil
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.
@@ -1,3 +1,3 @@
1
1
  module Elasticity
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -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 "elasticity_test_class_names"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: es-elasticity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Kochenburger