Sha256: d3bab2e253fc5e4d4c05e05694f58fbb09bb88d2214c12734410e5f9fcf91f40
Contents?: true
Size: 1.46 KB
Versions: 11
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true module WCC::Contentful class Engine < ::Rails::Engine initializer 'enable webhook' 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? WebhookEnableJob.set(wait: 10.seconds).perform_later if Rails.env.production? 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
11 entries across 11 versions & 1 rubygems