Sha256: 04f3bff2b367e3564cd201c95e4dccfdcdc08870b34cf47db2ec2043ca4c7e55

Contents?: true

Size: 880 Bytes

Versions: 8

Compression:

Stored size: 880 Bytes

Contents

module RailsConnector

class CouchBlob

  def self.find(id, options)
    cache_key = [:blob, id]
    attachment = Cache.load(cache_key)
    unless attachment
      ActiveSupport::Notifications.instrumenter.instrument("cms_load.rails_connector",
        :name => "Blob Load", :index => "blobs", :keys => [options[:context]]
      ) do
        attachment = CmsBaseModel.adapter.blob_attachment(id)
        Cache.store(cache_key, attachment)
      end
    end
    new(id, attachment)
  end

  def self.configure(spec)
    # connection is taken from CmsBaseModel on demand
  end

  attr_reader :id, :attachment

  def initialize(id, attachment)
    @id = id
    @attachment = attachment
  end

  def url
    CmsBaseModel.adapter.blob_url(id)
  end

  def content_type
    attachment["content_type"]
  end

  def length
    attachment['length']
  end

end

end # module RailsConnector

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.beta.200.785.05d4af9 lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.744.99f67fc lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.720.44fbabd lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.713.e5c3150 lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.681.7c84f4a lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.663.ceecdee lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.650.7c93155 lib/rails_connector/couch_blob.rb
infopark_cloud_connector-6.8.0.beta.200.621.4c8e1b0 lib/rails_connector/couch_blob.rb