Sha256: 461d0febd5bb2d81d56ceac1bcc57de96b6780d301d2ca70e68956ad35d28baa

Contents?: true

Size: 715 Bytes

Versions: 7

Compression:

Stored size: 715 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
        else
          raise NotImplementedError
        end

      klass.new(*args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adhoq-0.3.0 lib/adhoq/global_variable.rb
adhoq-0.2.0 lib/adhoq/global_variable.rb
adhoq-0.1.2 lib/adhoq/global_variable.rb
adhoq-0.1.1 lib/adhoq/global_variable.rb
adhoq-0.1.0 lib/adhoq/global_variable.rb
adhoq-0.0.7 lib/adhoq/global_variable.rb
adhoq-0.0.6 lib/adhoq/global_variable.rb