class Blobsterix::BlobAccess

Attributes

accept_type[RW]
bucket[RW]
id[RW]
source[RW]
target[RW]
trafo[RW]

Public Class Methods

new(atts={}) click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 6
def initialize(atts={})
  @trafo = []
  atts.each do |key,value| send("#{key}=",value) end
  identifier
end

Public Instance Methods

copy() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 28
def copy
  BlobAccess.new(:bucket => bucket, :id => id, :trafo => trafo, :accept_type => accept_type, :source => source, :target => target)
end
equals?(blob_access) click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 24
def equals?(blob_access)
  identifier == blob_access.identifier
end
get() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 20
def get
  @meta||=find_blob
end
identifier() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 12
def identifier
   @identifier||= "#{bucket}_#{id.gsub("/","_")}_#{trafo.map {|trafo_pair|"#{trafo_pair[0]}_#{trafo_pair[1]}"}.join(",")}.#{subtype}"
end
reset!() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 32
def reset!
  @meta = nil
  self
end
to_s() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 16
def to_s
  "BlobAccess: bucket(#{bucket}), id(#{id}), trafo(#{trafo}), accept_type(#{accept_type})"
end

Private Instance Methods

find_blob() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 39
def find_blob
  unless Blobsterix.cache.exists?(self)
    if trafo.empty? || raw_trafo?
      metaData = Blobsterix.storage.get(self.bucket, self.id)
      if raw_trafo? || raw_accept_type?(metaData.accept_type)
        load_from_storage(metaData)
      end
    end
  end || Blobsterix.cache.get(self)
end
load_from_storage(metaData) click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 58
def load_from_storage(metaData)
  return metaData unless Blobsterix.cache_original?
  Blobsterix.cache.put_raw(BlobAccess.new(:bucket => bucket, :id => id), metaData.data) if metaData.valid?
  return Blobsterix.cache.get(BlobAccess.new(:bucket => bucket, :id => id)) if metaData.valid?
  nil
end
raw_accept_type?(other) click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 54
def raw_accept_type?(other)
  @raw_accept_type||= (!accept_type || accept_type.equal?(other))
end
raw_trafo?() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 50
def raw_trafo?
  @raw_trafo||=(trafo.length == 1 && trafo[0][0]=="raw")
end
subtype() click to toggle source
# File lib/blobsterix/helper/blob_access.rb, line 66
def subtype
  accept_type ? accept_type.subtype : ""
end