Sha256: 1d857940064a63773db015a96631a8a79918e26a38c6d816820d4f280b507414

Contents?: true

Size: 1.5 KB

Versions: 26

Compression:

Stored size: 1.5 KB

Contents

module Attached
  module Storage
    class Base
      
      
      # Helper for parsing credentials from a hash, file, or string.
      #
      # Usage:
      #
      #   parse({...}) 
      #   parse(File.open(...))
      #   Parse("...")
      
      def parse(credentials)
        case credentials
        when Hash    then credentials
        when File    then YAML::load(credentials)[Rails.env]
        when String  then YAML::load(File.read(credentials))[Rails.env]
        else raise ArgumentError.new("credentials must be a hash, file, or string")
        end
      end
      
      
      # Create a new file system storage interface supporting save and destroy operations.
      #
      # Usage:
      #
      #   Base.new()
      
      def initialize(credentials = nil)
        raise NotImplementedError.new
      end
      
      
      # Access the host for a storage service or return null if local.
      #
      # Usage:
      #
      #   storage.host
      
      def host()
        raise NotImplementedError.new
      end
      
      
      # Save a file to a given path (abstract).
      #
      # Parameters:
      #
      # * file - The file to save.
      # * path - The path to save.
      
      def save(file, path)
        raise NotImplementedError.new
      end
      
      
      # Destroy a file at a given path (abstract).
      #
      # Parameters:
      #
      # * path - The path to destroy.
      
      def destroy(path)
        raise NotImplementedError.new
      end
      
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
attached-0.2.8 lib/attached/storage/base.rb
attached-0.2.7 lib/attached/storage/base.rb
attached-0.2.6 lib/attached/storage/base.rb
attached-0.2.5 lib/attached/storage/base.rb
attached-0.2.4 lib/attached/storage/base.rb
attached-0.2.3 lib/attached/storage/base.rb
attached-0.2.2 lib/attached/storage/base.rb
attached-0.2.1 lib/attached/storage/base.rb
attached-0.2.0 lib/attached/storage/base.rb
attached-0.1.9 lib/attached/storage/base.rb
attached-0.1.8 lib/attached/storage/base.rb
attached-0.1.7 lib/attached/storage/base.rb
attached-0.1.6 lib/attached/storage/base.rb
attached-0.1.5 lib/attached/storage/base.rb
attached-0.1.4 lib/attached/storage/base.rb
attached-0.1.3 lib/attached/storage/base.rb
attached-0.1.2 lib/attached/storage/base.rb
attached-0.1.1 lib/attached/storage/base.rb
attached-0.1.0 lib/attached/storage/base.rb
attached-0.0.9 lib/attached/storage/base.rb