Class: Consyncful::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_tagsObject

Returns the value of attribute content_tags.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def 
  @content_tags
end

#contentful_client_optionsObject

Returns the value of attribute contentful_client_options.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def contentful_client_options
  @contentful_client_options
end

#contentful_sync_optionsObject

Returns the value of attribute contentful_sync_options.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def contentful_sync_options
  @contentful_sync_options
end

#ignore_content_tagsObject

Returns the value of attribute ignore_content_tags.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def 
  @ignore_content_tags
end

#localeObject

Returns the value of attribute locale.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def locale
  @locale
end

#mongo_clientObject

Returns the value of attribute mongo_client.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def mongo_client
  @mongo_client
end

#mongo_collectionObject

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_timestampsObject

Returns the value of attribute preserve_contentful_timestamps.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def preserve_contentful_timestamps
  @preserve_contentful_timestamps
end

#sync_modeObject

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_requiredObject

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_passwordObject

Returns the value of attribute webhook_password.



18
19
20
# File 'lib/consyncful/configuration.rb', line 18

def webhook_password
  @webhook_password
end

#webhook_userObject

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_optionsObject



55
56
57
58
# File 'lib/consyncful/configuration.rb', line 55

def client_options
  options = @contentful_client_options
  options.reverse_merge!(DEFAULT_CLIENT_OPTIONS)
end

#initial_sync_optionsObject

rubocop:enable Metrics/MethodLength



49
50
51
52
53
# File 'lib/consyncful/configuration.rb', line 49

def initial_sync_options
  options = { initial: true }
  options = options.reverse_merge(@contentful_sync_options)
  options.reverse_merge(DEFAULT_SYNC_OPTIONS)
end