Sha256: 6065bb23fd26c2c76fabe79f2496c3e54b7bf7328742db2a47f4468eadb8fca0
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true module WCC::Contentful class Engine < ::Rails::Engine initializer 'enable webhook' do |app| app.config.to_prepare do config = WCC::Contentful.configuration jobs = [] jobs << WCC::Contentful::SyncEngine::Job if WCC::Contentful::Services.instance.sync_engine&.should_sync? jobs.push(*WCC::Contentful.configuration.webhook_jobs) jobs.each do |job| WCC::Contentful::WebhookController.subscribe( ->(event) do begin if job.respond_to?(:perform_later) job.perform_later(event.to_h) else Rails.logger.error "Misconfigured webhook job: #{job} does not respond to " \ ':perform_later' end rescue StandardError => e warn "Error in job #{job}: #{e}" Rails.logger.error "Error in job #{job}: #{e}" end end, with: :call ) end next unless config&.management_token.present? next unless config.app_url.present? if defined?(WCC::Contentful::WebhookEnableJob) WCC::Contentful::WebhookEnableJob.set(wait: 10.seconds).perform_later if Rails.env.production? else Rails.logger.error 'ActiveJob is not defined, webhook enable job will not run' end end end initializer 'wcc-contentful.deprecations' do |app| app.deprecators[:wcc_contentful] = WCC::Contentful.deprecator if app.respond_to?(:deprecators) end config.generators do |g| g.test_framework :rspec, fixture: false end # Clear the model registry to allow dev reloads to work properly # https://api.rubyonrails.org/classes/Rails/Railtie/Configuration.html#method-i-to_prepare config.to_prepare do WCC::Contentful::Model.reload! end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wcc-contentful-1.7.2 | lib/wcc/contentful/engine.rb |
wcc-contentful-1.7.1 | lib/wcc/contentful/engine.rb |
wcc-contentful-1.7.0 | lib/wcc/contentful/engine.rb |