Class: Renderful::Provider::Contentful
- Defined in:
- lib/renderful/provider/contentful.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #cache_keys_to_invalidate(webhook_body) ⇒ Object
- #cache_prefix ⇒ Object
- #find_entry(entry_id) ⇒ Object
-
#initialize(options) ⇒ Contentful
constructor
A new instance of Contentful.
Constructor Details
#initialize(options) ⇒ Contentful
Returns a new instance of Contentful.
6 7 8 9 10 |
# File 'lib/renderful/provider/contentful.rb', line 6 def initialize() super fail ArgumentError, 'contentful option is required!' unless contentful end |
Instance Method Details
#cache_keys_to_invalidate(webhook_body) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/renderful/provider/contentful.rb', line 23 def cache_keys_to_invalidate(webhook_body) params = webhook_body.is_a?(String) ? JSON.parse(webhook_body) : webhook_body keys_to_invalidate = [ContentEntry.build_cache_key(self, id: params['sys']['id'])] keys_to_invalidate += contentful.entries(links_to_entry: params['sys']['id']).map do |entry| ContentEntry.build_cache_key(self, id: entry.id) end { keys: keys_to_invalidate, patterns: [], } end |
#cache_prefix ⇒ Object
12 13 14 |
# File 'lib/renderful/provider/contentful.rb', line 12 def cache_prefix :contentful end |
#find_entry(entry_id) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/renderful/provider/contentful.rb', line 16 def find_entry(entry_id) entry = contentful.entry(entry_id) raise Error::EntryNotFoundError, entry_id unless entry wrap_entry(entry) end |