Class: WCC::Contentful::Store::CDNAdapter
- Inherits:
-
Object
- Object
- WCC::Contentful::Store::CDNAdapter
- Defined in:
- lib/wcc/contentful/store/cdn_adapter.rb
Defined Under Namespace
Classes: Query
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #find(key) ⇒ Object
- #find_all ⇒ Object
- #find_by(content_type:) ⇒ Object
-
#initialize(client) ⇒ CDNAdapter
constructor
A new instance of CDNAdapter.
Constructor Details
#initialize(client) ⇒ CDNAdapter
Returns a new instance of CDNAdapter.
7 8 9 |
# File 'lib/wcc/contentful/store/cdn_adapter.rb', line 7 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/wcc/contentful/store/cdn_adapter.rb', line 5 def client @client end |
Instance Method Details
#find(key) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/wcc/contentful/store/cdn_adapter.rb', line 11 def find(key) entry = begin client.entry(key, locale: '*') rescue WCC::Contentful::SimpleClient::NotFoundError client.asset(key, locale: '*') end entry&.raw end |
#find_all ⇒ Object
21 22 23 |
# File 'lib/wcc/contentful/store/cdn_adapter.rb', line 21 def find_all raise ArgumentError, 'use find_by content type instead' end |
#find_by(content_type:) ⇒ Object
25 26 27 |
# File 'lib/wcc/contentful/store/cdn_adapter.rb', line 25 def find_by(content_type:) Query.new(@client, content_type: content_type) end |