Sha256: 71deb9c24906072fd7e05b758803191cc8973b20eca1076fc04bebe706190fdd

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module Saviour
  class Config
    class NotImplemented
      def method_missing(*)
        raise(RuntimeError, "You need to provide a storage! Set Saviour::Config.storage = xxx")
      end
    end

    class << self
      def processing_enabled
        Thread.current["Saviour::Config"] ||= {}
        Thread.current["Saviour::Config"][:processing_enabled] || true
      end

      def processing_enabled=(value)
        Thread.current["Saviour::Config"] ||= {}
        Thread.current["Saviour::Config"][:processing_enabled] = value
      end

      def storage
        Thread.current["Saviour::Config"] ||= {}
        Thread.current["Saviour::Config"][:storage] || (Thread.main["Saviour::Config"] && Thread.main["Saviour::Config"][:storage]) || NotImplemented.new
      end

      def storage=(value)
        Thread.current["Saviour::Config"] ||= {}
        Thread.current["Saviour::Config"][:storage] = value

        if Thread.main["Saviour::Config"].nil?
          Thread.main["Saviour::Config"] ||= {}
          Thread.main["Saviour::Config"][:storage] = value
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saviour-0.4.0 lib/saviour/config.rb