krisleech/wisper-sidekiq

View on GitHub
lib/wisper/sidekiq/config.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Wisper
  module Sidekiq
    class Config
      class << self
        attr_reader :use_unsafe_yaml

        DEFAULT_SAFE_TYPES = [
          Class,
          Symbol,
          Time,
          Date,
          DateTime,
        ].freeze

        def use_unsafe_yaml!
          @use_unsafe_yaml = true
        end

        def use_safe_yaml!
          @use_unsafe_yaml = false
        end

        def safe_types
          @safe_types ||= DEFAULT_SAFE_TYPES
        end

        def register_safe_types(*types)
          @safe_types ||= DEFAULT_SAFE_TYPES
          @safe_types += types
          @safe_types.flatten!
          @safe_types.uniq!
        end
      end
    end

    class << self
      def configure
        yield Config
      end
    end
  end
end