Class: ActiveWebhook::Configuration

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/active_webhook/configuration.rb

Defined Under Namespace

Modules: Base Classes: InvalidOptionError

Constant Summary collapse

ADAPTERS =
%i[delivery formatting queueing verification].freeze

Instance Method Summary collapse

Methods included from Base

#initialize

Instance Method Details

#after_configureObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/active_webhook/configuration.rb', line 90

def after_configure
  # reset logger,
  # ActiveWebhook.class_variable_set(:@logger, nil)
  # cause all adapter files specified to be loaded
  ADAPTERS.each { |type| ActiveWebhook.send "#{type}_adapter" }

  # (re)set relationships for all models
  models.error_log.belongs_to :subscription, class_name: models.subscription.name, foreign_key: :subscription_id
  models.topic.has_many :subscriptions, class_name: models.subscription.name, foreign_key: :topic_id
  models.subscription.belongs_to :topic, class_name: models.topic.name, foreign_key: :topic_id
  models.subscription.has_many :error_logs, class_name: models.error_log.name, foreign_key: :subscription_id

  self
end

#origin=(value) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/active_webhook/configuration.rb', line 82

def origin=(value)
  if (@origin = value).nil?
    ActiveWebhook.remove_class_variable(:@@origin) if ActiveWebhook.class_variable_defined?(:@@origin)
  else
    ActiveWebhook.class_variable_set(:@@origin, value)
  end
end