Class: Inboxable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/inboxable/configuration.rb

Constant Summary collapse

ALLOWED_ORMS =
i[activerecord mongoid].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.

Raises:



7
8
9
10
11
12
13
14
15
# File 'lib/inboxable/configuration.rb', line 7

def initialize
  raise Error, 'Sidekiq is not available. Unfortunately, sidekiq must be available for Inboxable to work' unless Object.const_defined?('Sidekiq')
  raise Error, 'Inboxable Gem uses the sidekiq-cron Gem. Make sure you add it to your project' unless Object.const_defined?('Sidekiq::Cron')
  raise Error, 'Inboxable Gem only supports Rails but you application does not seem to be a Rails app' unless Object.const_defined?('Rails')
  raise Error, 'Inboxable Gem only support Rails version 7 and newer' if Rails::VERSION::MAJOR < 7

  Sidekiq::Options[:cron_poll_interval] = ENV.fetch('INBOXABLE__CRON_POLL_INTERVAL', 5).to_i
  Sidekiq::Cron::Job.create(name: 'InboxablePollingReceiver', cron: ENV.fetch('INBOXABLE__CRON', '*/5 * * * * *'), class: 'Inboxable::PollingReceiverWorker')
end

Instance Attribute Details

#inbox_modelObject

Returns the value of attribute inbox_model.



5
6
7
# File 'lib/inboxable/configuration.rb', line 5

def inbox_model
  @inbox_model
end

#ormObject

Returns the value of attribute orm.



5
6
7
# File 'lib/inboxable/configuration.rb', line 5

def orm
  @orm
end