Class: Refile::Fog::Backend
- Inherits:
-
Object
- Object
- Refile::Fog::Backend
- Extended by:
- BackendMacros
- Defined in:
- lib/refile/fog.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
Instance Method Summary collapse
- #clear!(confirm = nil) ⇒ Object
-
#initialize(directory:, max_size: nil, prefix: nil, hasher: Refile::RandomHasher.new, connection: nil, **options) ⇒ Backend
constructor
A new instance of Backend.
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, **) @connection = connection || ::Fog::Storage.new() @prefix = prefix @hasher = hasher @max_size = max_size @directory = @connection.directories.new(key: directory) end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
10 11 12 |
# File 'lib/refile/fog.rb', line 10 def directory @directory end |
#max_size ⇒ Object (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
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 |