Class: WCC::Contentful::Services
- Inherits:
-
Object
- Object
- WCC::Contentful::Services
- Includes:
- Singleton
- Defined in:
- lib/wcc/contentful/services.rb
Instance Method Summary collapse
-
#client ⇒ Object
Gets a CDN Client which provides methods for getting and paging raw JSON data from the Contentful CDN.
-
#management_client ⇒ Object
Gets a Management Client which provides methods for updating data via the Contentful Management API.
-
#preview_client ⇒ Object
Gets a CDN Client which provides methods for getting and paging raw JSON data from the Contentful Preview API.
-
#preview_store ⇒ Object
An instance of WCC::Contentful::Store::CDNAdapter which connects to the Contentful Preview API to return preview content.
-
#store ⇒ Object
Gets the data-store which executes the queries run against the dynamic models in the WCC::Contentful::Model namespace.
Instance Method Details
#client ⇒ Object
Gets a CDN Client which provides methods for getting and paging raw JSON data from the Contentful CDN.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/wcc/contentful/services.rb', line 57 def client @client ||= ensure_configured do |config| WCC::Contentful::SimpleClient::Cdn.new( access_token: config.access_token, space: config.space, default_locale: config.default_locale, adapter: config.http_adapter, environment: config.environment ) end end |
#management_client ⇒ Object
Gets a Management Client which provides methods for updating data via the Contentful Management API
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/wcc/contentful/services.rb', line 93 def management_client @management_client ||= ensure_configured do |config| if config.management_token.present? WCC::Contentful::SimpleClient::Management.new( management_token: config.management_token, space: config.space, default_locale: config.default_locale, adapter: config.http_adapter, environment: config.environment ) end end end |
#preview_client ⇒ Object
Gets a CDN Client which provides methods for getting and paging raw JSON data from the Contentful Preview API.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/wcc/contentful/services.rb', line 74 def preview_client @preview_client ||= ensure_configured do |config| if config.preview_token.present? WCC::Contentful::SimpleClient::Preview.new( preview_token: config.preview_token, space: config.space, default_locale: config.default_locale, adapter: config.http_adapter, environment: config.environment ) end end end |
#preview_store ⇒ Object
An instance of WCC::Contentful::Store::CDNAdapter which connects to the Contentful Preview API to return preview content.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wcc/contentful/services.rb', line 41 def preview_store @preview_store ||= ensure_configured do |config| WCC::Contentful::Store::Factory.new( config, self, :direct, [{ preview: true }] ).build_sync_store end end |
#store ⇒ Object
Gets the data-store which executes the queries run against the dynamic models in the WCC::Contentful::Model namespace. This is one of the following based on the configured content_delivery method:
- :direct
-
an instance of WCC::Contentful::Store::CDNAdapter with a CDN Client to access the CDN.
- :lazy_sync
-
an instance of WCC::Contentful::Store::LazyCacheStore with the configured ActiveSupport::Cache implementation and a CDN Client for when data cannot be found in the cache.
- :eager_sync
-
an instance of the configured Store type, defined by Configuration#sync_store
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wcc/contentful/services.rb', line 25 def store @store ||= ensure_configured do |config| WCC::Contentful::Store::Factory.new( config, self, config.content_delivery, config.content_delivery_params ).build_sync_store end end |