Class: Renderful::Client
- Inherits:
-
Object
- Object
- Renderful::Client
- Defined in:
- lib/renderful/client.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
-
#initialize(provider:, components:, cache: Cache::Null.new) ⇒ Client
constructor
A new instance of Client.
- #invalidate_cache_from_webhook(body) ⇒ Object
- #render(entry_id, options = {}) ⇒ Object
Constructor Details
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
5 6 7 |
# File 'lib/renderful/client.rb', line 5 def cache @cache end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
5 6 7 |
# File 'lib/renderful/client.rb', line 5 def components @components end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
5 6 7 |
# File 'lib/renderful/client.rb', line 5 def provider @provider end |
Instance Method Details
#invalidate_cache_from_webhook(body) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/renderful/client.rb', line 26 def invalidate_cache_from_webhook(body) result = provider.cache_keys_to_invalidate(body) cache.delete(*result[:keys]) if result[:keys].any? result[:patterns].each do |pattern| cache.delete_matched(pattern) end end |
#render(entry_id, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/renderful/client.rb', line 13 def render(entry_id, = {}) cache.fetch(ContentEntry.build_cache_key(provider, id: entry_id)) do content_entry = provider.find_entry(entry_id) component = component_for_entry(content_entry) if component.respond_to?(:render_in) component.render_in(.fetch(:view_context)) else component.render end end end |