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