Sha256: 474a2f9e67e4672ce715c62eec971a8bf3d6a8cecd7dc1178120ef320a1eac17

Contents?: true

Size: 767 Bytes

Versions: 6

Compression:

Stored size: 767 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
        when :on_the_fly then Adhoq::Storage::OnTheFly
        when :cache      then Adhoq::Storage::Cache
        else
          raise NotImplementedError
        end

      klass.new(*args)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adhoq-1.0.2 lib/adhoq/global_variable.rb
adhoq-1.0.1 lib/adhoq/global_variable.rb
adhoq-1.0.0 lib/adhoq/global_variable.rb
adhoq-0.5.0 lib/adhoq/global_variable.rb
adhoq-0.5.0.beta1 lib/adhoq/global_variable.rb
adhoq-0.4.0 lib/adhoq/global_variable.rb