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
-
#find(_id) ⇒ Object
abstract
Finds an entry by it’s ID.
-
#find_all(content_type:, options: nil) ⇒ Query
Finds all entries of the given content type.
-
#find_by(content_type:, filter: nil, options: nil) ⇒ Object
Finds the first entry matching the given filter.
-
#index(_json) ⇒ Object
Processes a data point received via the Sync API.
-
#index? ⇒ Boolean
Returns true if this store can persist entries and assets which are retrieved from the sync API.
Instance Method Details
#find(_id) ⇒ Object
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))
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)
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))
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))
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)
22 23 24 |
# File 'lib/wcc/contentful/store/interface.rb', line 22 def index? raise NotImplementedError, "#{self.class} does not implement #index?" end |