Class: Ecoportal::API::GraphQL::Compat::SearchResults

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ecoportal/api/graphql/compat/search_results.rb

Overview

Wraps a GraphQL connection object to expose the v2-compatible search result interface. eco-helpers scripts access: search_results.total — filtered count search_results.total_before_filtering — pre-filter count (approximated) (also Enumerable for iteration)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ SearchResults

Returns a new instance of SearchResults.



15
16
17
18
19
20
# File 'lib/ecoportal/api/graphql/compat/search_results.rb', line 15

def initialize(connection)
  @total                  = connection.totalCount
  # GraphQL does not expose a pre-filter count — use the same value.
  @total_before_filtering = connection.totalCount
  @nodes                  = connection.nodes
end

Instance Attribute Details

#totalObject (readonly)

Returns the value of attribute total.



13
14
15
# File 'lib/ecoportal/api/graphql/compat/search_results.rb', line 13

def total
  @total
end

#total_before_filteringObject (readonly)

Returns the value of attribute total_before_filtering.



13
14
15
# File 'lib/ecoportal/api/graphql/compat/search_results.rb', line 13

def total_before_filtering
  @total_before_filtering
end

Instance Method Details

#each(&block) ⇒ Object



22
23
24
# File 'lib/ecoportal/api/graphql/compat/search_results.rb', line 22

def each(&block)
  @nodes.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ecoportal/api/graphql/compat/search_results.rb', line 26

def empty?
  @nodes.empty?
end