Class: LedgerSync::Ledgers::TestLedger::Searcher

Inherits:
Searcher
  • Object
show all
Includes:
Mixins::OffsetAndLimitPaginationSearcherMixin
Defined in:
lib/ledger_sync/test/support/test_ledger/searcher.rb

Instance Attribute Summary

Attributes inherited from Searcher

#client, #pagination, #query, #request

Instance Method Summary collapse

Methods included from Mixins::OffsetAndLimitPaginationSearcherMixin

#next_searcher, #previous_searcher

Methods inherited from Searcher

#deserializer_class, #initialize, #next_searcher, #previous_searcher

Methods included from Mixins::SerializationMixin

#deserializer, included, #serializer

Methods included from Mixins::InferSerializerMixin

included

Methods included from Mixins::InferResourceClassMixin

included

Constructor Details

This class inherits a constructor from LedgerSync::Ledgers::Searcher

Instance Method Details

#query_stringObject



9
10
11
# File 'lib/ledger_sync/test/support/test_ledger/searcher.rb', line 9

def query_string
  ''
end

#resourcesObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ledger_sync/test/support/test_ledger/searcher.rb', line 13

def resources
  resource_class = self.class.inferred_resource_class

  response = client.query(
    limit: limit,
    offset: offset,
    query: query_string,
    resource_class: resource_class
  )
  return [] if response.body.blank?

  (response.body.dig(
    'QueryResponse',
    client.class.ledger_resource_type_for(
      resource_class: resource_class
    ).classify
  ) || []).map do |c|
    self.class.inferred_deserializer_class.new.deserialize(
      hash: c,
      resource: resource_class.new
    )
  end
end

#searchObject



37
38
39
40
41
42
# File 'lib/ledger_sync/test/support/test_ledger/searcher.rb', line 37

def search
  super
rescue => e # rubocop:disable Style/RescueStandardError
  @response = e # TODO: Better catch/raise errors as LedgerSync::Error
  failure
end