Sha256: 2e385c47d5205977244416f4843387533adec48bf84d8b45cfdc9f06f02cdb26

Contents?: true

Size: 750 Bytes

Versions: 86

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module GoodJob
  class Setting < BaseRecord
    CRON_KEYS_DISABLED = "cron_keys_disabled"

    self.table_name = 'good_job_settings'

    def self.cron_key_enabled?(key)
      cron_disabled = find_by(key: CRON_KEYS_DISABLED)&.value || []
      cron_disabled.exclude?(key.to_s)
    end

    def self.cron_key_enable(key)
      setting = GoodJob::Setting.find_by(key: CRON_KEYS_DISABLED)
      return unless setting&.value&.include?(key.to_s)

      setting.value.delete(key.to_s)
      setting.save!
    end

    def self.cron_key_disable(key)
      setting = find_or_initialize_by(key: CRON_KEYS_DISABLED) do |record|
        record.value = []
      end
      setting.value << key
      setting.save!
    end
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
good_job-3.18.2 app/models/good_job/setting.rb
good_job-3.18.1 app/models/good_job/setting.rb
good_job-3.18.0 app/models/good_job/setting.rb
good_job-3.17.4 app/models/good_job/setting.rb
good_job-3.17.3 app/models/good_job/setting.rb
good_job-3.17.2 app/models/good_job/setting.rb
good_job-3.17.1 app/models/good_job/setting.rb
good_job-3.17.0 app/models/good_job/setting.rb
good_job-3.16.4 app/models/good_job/setting.rb
good_job-3.16.3 app/models/good_job/setting.rb
good_job-3.16.2 app/models/good_job/setting.rb
good_job-3.16.1 app/models/good_job/setting.rb
good_job-3.16.0 app/models/good_job/setting.rb
good_job-3.15.14 app/models/good_job/setting.rb
good_job-3.15.13 app/models/good_job/setting.rb
good_job-3.15.12 app/models/good_job/setting.rb
good_job-3.15.11 app/models/good_job/setting.rb
good_job-3.15.10 app/models/good_job/setting.rb
good_job-3.15.9 app/models/good_job/setting.rb
good_job-3.15.8 app/models/good_job/setting.rb