Sha256: b3bfbe6f16d266d5fb856f05b34f80dd1a790f18301097770d258aeaf02108cc

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

require 'monitor'

module Adhoq
  module GlobalVariable
    def self.extended(base)
      base.extend MonitorMixin
    end

    def current_storage
      synchronize {
        @current_storage ||= setup_storage(*Adhoq.config.storage)
      }
    end

    def configure(&block)
      yield config
    end

    def config
      @config ||= Adhoq::Configuration.new
    end

    private

    def setup_storage(type, *args)
      klass =
        case type
        when :local_file then Adhoq::Storage::LocalFile
        when :s3         then Adhoq::Storage::S3
        else
          raise NotImplementedError
        end

      klass.new(*args)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adhoq-0.0.5 lib/adhoq/global_variable.rb
adhoq-0.0.4 lib/adhoq/global_variable.rb
adhoq-0.0.3 lib/adhoq/global_variable.rb