Module: BetterStorage::Blob

Defined in:
lib/better_storage/blob.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



14
15
16
17
18
# File 'lib/better_storage/blob.rb', line 14

def delete
  service.delete(key)
  # original implementation is `service.delete_prefixed("variants/#{key}/") if image?`
  service.delete_prefixed(variant_prefix) if image?
end

#keyObject



3
4
5
6
7
8
# File 'lib/better_storage/blob.rb', line 3

def key
  self[:key] ||= begin
    key = self.class.generate_unique_secure_token(length: self.class::MINIMUM_TOKEN_LENGTH)
    BetterStorage.generate_blob_key(key)
  end
end

#public_urlObject



10
11
12
# File 'lib/better_storage/blob.rb', line 10

def public_url
  BetterStorage.public_url(key)
end

#variant_prefixObject



20
21
22
# File 'lib/better_storage/blob.rb', line 20

def variant_prefix
  "#{key}/variants/"
end