module WCC::Contentful::Store::Interface
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
Constants
- INTERFACE_METHODS
Public Instance Methods
Finds an entry by it's ID. The returned entry is a JSON hash @abstract Subclasses should implement this at a minimum to provide data
to the WCC::Contentful::Model API.
sig {abstract.params(id: String).returns(T.any(Entry, Asset))}
# File lib/wcc/contentful/store/interface.rb, line 40 def find(_id) raise NotImplementedError, "#{self.class} does not implement #find" end
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.
@param [String] content_type The ID of the content type to search for. @param [Hash] options An optional set of additional parameters to the query
defining for example include depth. Not all store implementations respect all options.
@return [Query] A query object that exposes methods to apply filters.
@see WCC::Contentful::Store::Query::Interface
sig {abstract.params(
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
)}
# 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
Finds the first entry matching the given filter. A content type is required.
@param [String] content_type The ID of the content type to search for. @param [Hash] filter A set of key-value pairs defining filter operations.
See WCC::Contentful::Store::Base::Query
@param [Hash] options An optional set of additional parameters to the query
defining for example include depth. Not all store implementations respect all options.
sig {abstract.params(
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))}
# 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
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 {abstract.params(json: T.any(Entry, Asset, DeletedEntry, DeletedAsset))
.returns(T.any(Entry, Asset, nil))}
# File lib/wcc/contentful/store/interface.rb, line 32 def index(_json) raise NotImplementedError, "#{self.class} does not implement #index" end
Returns true if this store can persist entries and assets which are retrieved from the sync API. sig {abstract.returns(T::Boolean)}
# File lib/wcc/contentful/store/interface.rb, line 22 def index? raise NotImplementedError, "#{self.class} does not implement #index?" end