Sha256: 03dfbd354bef0514d117cf988c1b028a852274f1f7bf3afe5479e8d930b8e10a

Contents?: true

Size: 1.14 KB

Versions: 13

Compression:

Stored size: 1.14 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

13 entries across 13 versions & 1 rubygems

Version Path
attached-1.0.4 lib/attached/storage.rb
attached-1.0.3 lib/attached/storage.rb
attached-1.0.2 lib/attached/storage.rb
attached-1.0.1 lib/attached/storage.rb
attached-1.0.0 lib/attached/storage.rb
attached-0.6.0 lib/attached/storage.rb
attached-0.5.9 lib/attached/storage.rb
attached-0.5.8 lib/attached/storage.rb
attached-0.5.7 lib/attached/storage.rb
attached-0.5.6 lib/attached/storage.rb
attached-0.5.5 lib/attached/storage.rb
attached-0.5.4 lib/attached/storage.rb
attached-0.5.3 lib/attached/storage.rb