Class: Refile::Fog::Backend

Inherits:
Object
  • Object
show all
Extended by:
BackendMacros
Defined in:
lib/refile/fog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory:, max_size: nil, prefix: nil, hasher: Refile::RandomHasher.new, connection: nil, **options) ⇒ Backend

Returns a new instance of Backend.


12
13
14
15
16
17
18
19
# File 'lib/refile/fog.rb', line 12

def initialize(directory:, max_size: nil, prefix: nil, hasher: Refile::RandomHasher.new, connection: nil, **options)
  @connection = connection || ::Fog::Storage.new(options)
  @prefix = prefix
  @hasher = hasher
  @max_size = max_size

  @directory = @connection.directories.new(key: directory)
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory


10
11
12
# File 'lib/refile/fog.rb', line 10

def directory
  @directory
end

#max_sizeObject (readonly)

Returns the value of attribute max_size


10
11
12
# File 'lib/refile/fog.rb', line 10

def max_size
  @max_size
end

Instance Method Details

#clear!(confirm = nil) ⇒ Object

Raises:

  • (Refile::Confirm)

60
61
62
63
# File 'lib/refile/fog.rb', line 60

def clear!(confirm = nil)
  raise Refile::Confirm unless confirm == :confirm
  @directory.files.select { |f| f.key.start_with?(@prefix.to_s) }.each(&:destroy)
end