Sha256: 8434df24eed525930fdb8b01ebf6eb6093979f6c8e21a8392e8fbc7959f81758

Contents?: true

Size: 998 Bytes

Versions: 7

Compression:

Stored size: 998 Bytes

Contents

require "aws-sdk"

module RailsConnector

class Blob

  def self.find(id, options)
    new(blob_class.find(id, options))
  end

  def self.config
    @config or raise "Blob storage has not been configured yet"
  end

  def self.configure(spec)
    @config = spec.symbolize_keys
  end

  def self.blob_class
    @blob_class ||= blob_class_from_config
  end

  # for testing purposes
  def self.reset_blob_class_cache # :nodoc:
    @blob_class = nil
  end

  def self.blob_class_from_config
    blob_class =
        case config[:type]
        when "s3"
          S3Blob
        else
          raise "Unsupported blob storage type #{config[:type]}"
        end
    blob_class.configure(config)
    blob_class
  end

  attr_reader :instance

  def initialize(blob_instance)
    @instance = blob_instance
  end

  def id
    instance.id
  end

  def url
    instance.url
  end

  def content_type
    instance.content_type
  end

  def length
    instance.length
  end

end

end # module RailsConnector

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.23.da7f96b lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.16.def5e85 lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.15.a24f5ff lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.beta.200.891.647580e lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.beta.200.889.d503e42 lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.beta.200.883.f5f063b lib/rails_connector/blob.rb
infopark_cloud_connector-6.8.0.beta.200.884.4bd86e6 lib/rails_connector/blob.rb