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.15.7 app/models/good_job/setting.rb
good_job-3.15.6 app/models/good_job/setting.rb
good_job-3.15.5 app/models/good_job/setting.rb
good_job-3.15.4 app/models/good_job/setting.rb
good_job-3.15.3 app/models/good_job/setting.rb
good_job-3.15.2 app/models/good_job/setting.rb
good_job-3.15.1 app/models/good_job/setting.rb
good_job-3.15.0 app/models/good_job/setting.rb
good_job-3.14.2 app/models/good_job/setting.rb
good_job-3.14.1 app/models/good_job/setting.rb
good_job-3.14.0 app/models/good_job/setting.rb
good_job-3.13.0 app/models/good_job/setting.rb
good_job-3.12.8 app/models/good_job/setting.rb
good_job-3.12.7 app/models/good_job/setting.rb
good_job-3.12.6 app/models/good_job/setting.rb
good_job-3.12.5 app/models/good_job/setting.rb
good_job-3.12.4 app/models/good_job/setting.rb
good_job-3.12.3 app/models/good_job/setting.rb
good_job-3.12.2 app/models/good_job/setting.rb
good_job-3.12.1 app/models/good_job/setting.rb