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

Included in:
Middleware::Store, Base, CDNAdapter
Defined in:
lib/wcc/contentful/store/interface.rb

Overview

This module represents the common interface of all Store implementations. It is documentation ONLY and does not add functionality.

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

Constant Summary collapse

INTERFACE_METHODS =
WCC::Contentful::Store::Interface.instance_methods - Module.instance_methods

Instance Method Summary collapse

Instance Method Details

#find(_id) ⇒ Object

This method is abstract.

Subclasses should implement this at a minimum to provide data to the WCC::Contentful::Model API.

Finds an entry by it’s ID. The returned entry is a JSON hash sig String).returns(T.any(Entry, Asset))

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/wcc/contentful/store/interface.rb', line 40

def find(_id)
  raise NotImplementedError, "#{self.class} does not implement #find"
end

#find_all(content_type:, options: nil) ⇒ Query

Finds all entries of the given content type. A content type is required.

Subclasses may override this to provide their own query implementation,

or else override #execute to run the query after it has been parsed.

sig

content_type: String,
filter: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
options: T.nilable(T::Hash[T.any(Symbol), T.untyped]),

).returns(WCC::Contentful::Store::Query::Interface)

Parameters:

  • content_type (String)

    The ID of the content type to search for.

  • options (Hash) (defaults to: nil)

    An optional set of additional parameters to the query defining for example include depth. Not all store implementations respect all options.

Returns:

  • (Query)

    A query object that exposes methods to apply filters. @see WCC::Contentful::Store::Query::Interface

Raises:

  • (NotImplementedError)


75
76
77
# File 'lib/wcc/contentful/store/interface.rb', line 75

def find_all(content_type:, options: nil)
  raise NotImplementedError, "#{self.class} does not implement #find_all"
end

#find_by(content_type:, filter: nil, options: nil) ⇒ Object

Finds the first entry matching the given filter. A content type is required.

sig

content_type: String,
filter: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]),
options: T.nilable(T::Hash[T.any(Symbol), T.untyped]),

).returns(T.any(Entry, Asset))

Parameters:

  • content_type (String)

    The ID of the content type to search for.

  • filter (Hash) (defaults to: nil)

    A set of key-value pairs defining filter operations. See WCC::Contentful::Store::Base::Query

  • options (Hash) (defaults to: nil)

    An optional set of additional parameters to the query defining for example include depth. Not all store implementations respect all options.

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/wcc/contentful/store/interface.rb', line 56

def find_by(content_type:, filter: nil, options: nil)
  raise NotImplementedError, "#{self.class} does not implement #find_by"
end

#index(_json) ⇒ Object

Processes a data point received via the Sync API. This can be a published entry or asset, or a ‘DeletedEntry’ or ‘DeletedAsset’. The default implementation calls into #set and #delete to perform the appropriate operations in the store. sig T.any(Entry, Asset, DeletedEntry, DeletedAsset))

.returns(T.any(Entry, Asset, nil))

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/wcc/contentful/store/interface.rb', line 32

def index(_json)
  raise NotImplementedError, "#{self.class} does not implement #index"
end

#index?Boolean

Returns true if this store can persist entries and assets which are retrieved from the sync API. sig WCC::Contentful::Store::Interface.abstractabstract.returns(Tabstract.returns(T::Boolean)

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/wcc/contentful/store/interface.rb', line 22

def index?
  raise NotImplementedError, "#{self.class} does not implement #index?"
end