Sha256: 65daf622890552fa7d6a0c8c75aa5919be0cf0a0f73e068d2fbbca12bd0f2fa0

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'attached/storage/base'
require 'attached/storage/aws'
require 'attached/storage/google'
require 'attached/storage/rackspace'
require 'attached/storage/local'

module Attached
  module Storage

    # Create a storage object given a medium and credentials.
    #
    # Usage:
    #
    #   Attached::Storage.storage(:local)
    #   Attached::Storage.storage(:aws,       "#{Rails.root}/config/aws.yml"      )
    #   Attached::Storage.storage(:google,    "#{Rails.root}/config/google.yml"   )
    #   Attached::Storage.storage(:rackspace, "#{Rails.root}/config/rackspace.yml")
    #   Attached::Storage.storage(Attached::Storage::Custom.new)

    def self.storage(storage, credentials)
      return storage if storage.is_a? Attached::Storage::Base
      case storage
        when :aws then return Attached::Storage::AWS.new credentials
        when :google then return Attached::Storage::Google.new credentials
        when :rackspace then return Attached::Storage::Rackspace.new credentials
        when :local then return Attached::Storage::Local.new
        else raise "undefined storage '#{storage}'"
      end
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attached-1.0.7 lib/attached/storage.rb
attached-1.0.6 lib/attached/storage.rb
attached-1.0.5 lib/attached/storage.rb