Module: WCC::Contentful::Store::Query::Interface

Includes:
Enumerable
Included in:
Middleware::Store::DelegatingQuery, CDNAdapter::Query, WCC::Contentful::Store::Query
Defined in:
lib/wcc/contentful/store/query/interface.rb

Overview

This module represents the common interface of queries that must be returned by a store’s #find_all implementation. It is documentation ONLY and does not add functionality.

This is distinct from WCC::Contentful::Store::Query, because certain helpers exposed publicly by that abstract class are not part of the actual interface and can change without a major version update.

Constant Summary collapse

OPERATORS =

The set of operators that can be applied to a query. Not all stores implement all operators. At a bare minimum a store must implement #eq.

%i[
  eq
  ne
  all
  in
  nin
  exists
  lt
  lte
  gt
  gte
  query
  match
].freeze

Instance Method Summary collapse

Instance Method Details

#apply(_filter, _context = nil) ⇒ Object

Called with a filter object in order to apply the filter. The filter in this case is a hash where the keys are paths and the values are expectations.

sig

  field: T.any(T::String),
  expected: T.untyped,
  context: T.nilable(T::Hash[T.untyped, T.untyped])
).returns(T.self_type)

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/wcc/contentful/store/query/interface.rb', line 59

def apply(_filter, _context = nil)
  raise NotImplementedError, "#{self.class} does not implement #apply"
end

#eq(_field, _expected, _context = nil) ⇒ Object

Applies an equality condition to the query. The underlying store translates this into a ‘==’ check.

sig

  field: T.any(T::String),
  expected: T.untyped,
  context: T.nilable(T::Hash[T.untyped, T.untyped])
).returns(T.self_type)

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/wcc/contentful/store/query/interface.rb', line 46

def eq(_field, _expected, _context = nil)
  raise NotImplementedError, "#{self.class} does not implement #eq"
end