class WCC::Contentful::Store::CDNAdapter
Attributes
client[W]
Note: CDNAdapter
should not instrument store events cause it's not a store.
preview_client[W]
Note: CDNAdapter
should not instrument store events cause it's not a store.
Public Class Methods
new(client = nil, preview: false)
click to toggle source
Intentionally not implementing write methods
Calls superclass method
# File lib/wcc/contentful/store/cdn_adapter.rb, line 25 def initialize(client = nil, preview: false) super() @client = client @preview = preview end
Public Instance Methods
client()
click to toggle source
# File lib/wcc/contentful/store/cdn_adapter.rb, line 10 def client @preview ? @preview_client : @client end
find(key, hint: nil, **options)
click to toggle source
# File lib/wcc/contentful/store/cdn_adapter.rb, line 31 def find(key, hint: nil, **options) options = { locale: '*' }.merge!(options || {}) entry = if hint client.public_send(hint.underscore, key, options) else begin client.entry(key, options) rescue WCC::Contentful::SimpleClient::NotFoundError client.asset(key, options) end end entry&.raw rescue WCC::Contentful::SimpleClient::NotFoundError nil end
find_all(content_type:, options: nil)
click to toggle source
# File lib/wcc/contentful/store/cdn_adapter.rb, line 55 def find_all(content_type:, options: nil) Query.new( self, client: client, relation: { content_type: content_type }, options: options ) end
find_by(content_type:, filter: nil, options: nil)
click to toggle source
# File lib/wcc/contentful/store/cdn_adapter.rb, line 48 def find_by(content_type:, filter: nil, options: nil) # default implementation - can be overridden q = find_all(content_type: content_type, options: { limit: 1 }.merge!(options || {})) q = q.apply(filter) if filter q.first end
index()
click to toggle source
# File lib/wcc/contentful/store/cdn_adapter.rb, line 19 def index raise NotImplementedError, 'Cannot put data to the CDN!' end
index?()
click to toggle source
The CDNAdapter
cannot index data coming back from the Sync API.
# File lib/wcc/contentful/store/cdn_adapter.rb, line 15 def index? false end