Class: Consyncful::Configuration
- Inherits:
-
Object
- Object
- Consyncful::Configuration
- Defined in:
- lib/consyncful/configuration.rb
Overview
Provides configuration options for Consyncful, including:
-
Contentful API client and sync options
-
MongoDB client and collection settings
-
Locale and content tag filtering
-
Sync mode (poll or webhook)
-
Webhook authentication credentials
This class is typically accessed and customized via
Consyncful.configure do |config|
config.locale = 'en-NZ'
config.mongo_collection = 'my_models'
end
Instance Attribute Summary collapse
-
#content_tags ⇒ Object
Returns the value of attribute content_tags.
-
#contentful_client_options ⇒ Object
Returns the value of attribute contentful_client_options.
-
#contentful_sync_options ⇒ Object
Returns the value of attribute contentful_sync_options.
-
#ignore_content_tags ⇒ Object
Returns the value of attribute ignore_content_tags.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#mongo_client ⇒ Object
Returns the value of attribute mongo_client.
-
#mongo_collection ⇒ Object
Returns the value of attribute mongo_collection.
-
#preserve_contentful_timestamps ⇒ Object
Returns the value of attribute preserve_contentful_timestamps.
-
#sync_mode ⇒ Object
Returns the value of attribute sync_mode.
-
#webhook_authentication_required ⇒ Object
Returns the value of attribute webhook_authentication_required.
-
#webhook_password ⇒ Object
Returns the value of attribute webhook_password.
-
#webhook_user ⇒ Object
Returns the value of attribute webhook_user.
Instance Method Summary collapse
- #client_options ⇒ Object
-
#initial_sync_options ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#initialize ⇒ Configuration
constructor
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize ⇒ Configuration
rubocop:disable Metrics/MethodLength
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/consyncful/configuration.rb', line 32 def initialize @sync_mode = :poll @contentful_client_options = {} @contentful_sync_options = {} @locale = 'en-NZ' @mongo_client = :default @mongo_collection = 'contentful_models' @content_tags = [] @ignore_content_tags = [] @preserve_contentful_timestamps = false @webhook_authentication_required = true @webhook_user = nil @webhook_password = nil end |
Instance Attribute Details
#content_tags ⇒ Object
Returns the value of attribute content_tags.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def @content_tags end |
#contentful_client_options ⇒ Object
Returns the value of attribute contentful_client_options.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def @contentful_client_options end |
#contentful_sync_options ⇒ Object
Returns the value of attribute contentful_sync_options.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def @contentful_sync_options end |
#ignore_content_tags ⇒ Object
Returns the value of attribute ignore_content_tags.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def @ignore_content_tags end |
#locale ⇒ Object
Returns the value of attribute locale.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def locale @locale end |
#mongo_client ⇒ Object
Returns the value of attribute mongo_client.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def mongo_client @mongo_client end |
#mongo_collection ⇒ Object
Returns the value of attribute mongo_collection.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def mongo_collection @mongo_collection end |
#preserve_contentful_timestamps ⇒ Object
Returns the value of attribute preserve_contentful_timestamps.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def @preserve_contentful_timestamps end |
#sync_mode ⇒ Object
Returns the value of attribute sync_mode.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def sync_mode @sync_mode end |
#webhook_authentication_required ⇒ Object
Returns the value of attribute webhook_authentication_required.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def webhook_authentication_required @webhook_authentication_required end |
#webhook_password ⇒ Object
Returns the value of attribute webhook_password.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def webhook_password @webhook_password end |
#webhook_user ⇒ Object
Returns the value of attribute webhook_user.
18 19 20 |
# File 'lib/consyncful/configuration.rb', line 18 def webhook_user @webhook_user end |
Instance Method Details
#client_options ⇒ Object
55 56 57 58 |
# File 'lib/consyncful/configuration.rb', line 55 def = @contentful_client_options .reverse_merge!(DEFAULT_CLIENT_OPTIONS) end |
#initial_sync_options ⇒ Object
rubocop:enable Metrics/MethodLength
49 50 51 52 53 |
# File 'lib/consyncful/configuration.rb', line 49 def = { initial: true } = .reverse_merge(@contentful_sync_options) .reverse_merge(DEFAULT_SYNC_OPTIONS) end |