agnostic_backend 0.9.3 → 0.9.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: 54f7efb9627bf822b2a0503a728f3cb0097d4834
4
- data.tar.gz: 7e54f4102bdb38fdb99cd7d6a42feaa414b8ad50
3
+ metadata.gz: f379b563c7fa6fc0d4fbbef69222931eaaa0efc0
4
+ data.tar.gz: cedf4be31fc43e9576fdcb49586427fcffd67dc2
5
5
  SHA512:
6
- metadata.gz: bf3b8ef2efaca8c8ec003eff38710f6c7f0148d3cdef777159ab5930a97c76723f0d1cfa296874b83172aa710379edde339a71e1c4b308bef91538631be81074
7
- data.tar.gz: e7c7f82ce2bb0762e8a6e352b4913f08b9f37ccea1ed784d04726003e629cd8002b54c83d158077925ce6f05716518133ea5f9b8107fb6f6060c246f31d61e07
6
+ metadata.gz: 2dc5e38d7662a707d082e275a89450157dad30aa518f9c0bc19bf6dc097d2b44b93baf397d5598e12f94ccc7d6fd4b378404adc3d85ea814046fa99fbbe23b31
7
+ data.tar.gz: d2ad6dbdae2102814a100a4588365d67ad0b8c04806c21145db590370b96b1cdc6a366d10ddc4ba0045961f786d71d954878bab3a7d4d27895f7d9510b80f4b5
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg
3
3
  *.gem
4
4
  tags
5
5
  gems.tags
6
+ Gemfile.lock
@@ -8,6 +8,7 @@ require 'agnostic_backend/indexable/config'
8
8
  require 'agnostic_backend/indexable/field_type'
9
9
  require 'agnostic_backend/indexable/field'
10
10
  require 'agnostic_backend/indexable/content_manager'
11
+ require 'agnostic_backend/indexable/object_observer'
11
12
 
12
13
  require 'agnostic_backend/index'
13
14
  require 'agnostic_backend/indexer'
@@ -30,12 +30,13 @@ module AgnosticBackend
30
30
  from: from, **options)
31
31
  end
32
32
 
33
- def extract_contents_from(object, index_name)
33
+ def extract_contents_from(object, index_name, observer:)
34
34
  kv_pairs = contents.map do |field_name, field|
35
35
  field_value = field.evaluate(context: object)
36
36
  if field.type.nested?
37
37
  if field_value.respond_to? :generate_document
38
- field_value = field_value.generate_document(for_index: index_name)
38
+ observer.add(field_value)
39
+ field_value = field_value.generate_document(for_index: index_name, observer: observer)
39
40
  elsif field_value.present?
40
41
  field_name = nil
41
42
  end
@@ -88,12 +88,13 @@ module AgnosticBackend
88
88
  self.class.index_name(source)
89
89
  end
90
90
 
91
- def generate_document(for_index: nil)
91
+ def generate_document(for_index: nil, observer: nil)
92
92
  index_name = for_index.nil? ? self.index_name : for_index.to_s
93
93
  return unless respond_to? :_index_content_managers
94
94
  manager = _index_content_managers[index_name.to_s]
95
95
  raise "Index #{index_name} does not exist" if manager.nil?
96
- manager.extract_contents_from self, index_name
96
+ observer ||= AgnosticBackend::Indexable::ObjectObserver.new
97
+ manager.extract_contents_from self, index_name, observer: observer
97
98
  end
98
99
 
99
100
  def put_to_index(index_name=nil)
@@ -0,0 +1,17 @@
1
+ module AgnosticBackend
2
+ module Indexable
3
+
4
+ class CircularReferenceError < StandardError; end
5
+
6
+ class ObjectObserver
7
+ def initialize
8
+ @objects = Set.new
9
+ end
10
+
11
+ def add(obj)
12
+ raise CircularReferenceError.new(obj) if @objects.include? obj
13
+ @objects << obj
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module AgnosticBackend
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agnostic_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iasonas Gavriilidis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2016-03-23 00:00:00.000000000 Z
13
+ date: 2016-06-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -126,7 +126,6 @@ files:
126
126
  - ".travis.yml"
127
127
  - CODE_OF_CONDUCT.md
128
128
  - Gemfile
129
- - Gemfile.lock
130
129
  - LICENSE.txt
131
130
  - README.md
132
131
  - Rakefile
@@ -146,6 +145,7 @@ files:
146
145
  - lib/agnostic_backend/indexable/field.rb
147
146
  - lib/agnostic_backend/indexable/field_type.rb
148
147
  - lib/agnostic_backend/indexable/indexable.rb
148
+ - lib/agnostic_backend/indexable/object_observer.rb
149
149
  - lib/agnostic_backend/indexer.rb
150
150
  - lib/agnostic_backend/queryable/attribute.rb
151
151
  - lib/agnostic_backend/queryable/cloudsearch/executor.rb
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- agnostic_backend (0.9.3)
5
- activesupport (~> 3)
6
- aws-sdk (~> 2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (3.2.22.2)
12
- i18n (~> 0.6, >= 0.6.4)
13
- multi_json (~> 1.0)
14
- aws-sdk (2.2.29)
15
- aws-sdk-resources (= 2.2.29)
16
- aws-sdk-core (2.2.29)
17
- jmespath (~> 1.0)
18
- aws-sdk-resources (2.2.29)
19
- aws-sdk-core (= 2.2.29)
20
- diff-lcs (1.2.5)
21
- docile (1.1.5)
22
- i18n (0.7.0)
23
- jmespath (1.1.3)
24
- json (1.8.3)
25
- multi_json (1.11.2)
26
- rake (10.5.0)
27
- rspec (2.99.0)
28
- rspec-core (~> 2.99.0)
29
- rspec-expectations (~> 2.99.0)
30
- rspec-mocks (~> 2.99.0)
31
- rspec-core (2.99.2)
32
- rspec-expectations (2.99.2)
33
- diff-lcs (>= 1.1.3, < 2.0)
34
- rspec-mocks (2.99.4)
35
- simplecov (0.11.2)
36
- docile (~> 1.1.0)
37
- json (~> 1.8)
38
- simplecov-html (~> 0.10.0)
39
- simplecov-html (0.10.0)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- agnostic_backend!
46
- bundler
47
- rake (~> 10)
48
- rspec (~> 2)
49
- simplecov
50
- simplecov-html
51
-
52
- BUNDLED WITH
53
- 1.11.2