Class: Syncbox::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/syncbox/store.rb

Constant Summary collapse

STORES =
{ "S3" => "S3Bucket", "Glacier" => "Glacier"}

Instance Method Summary collapse

Constructor Details

#initialize(store, options = {}) ⇒ Store

Initializes a store object

Parameters:

  • store (String)
  • options (HASH) (defaults to: {})

Raises:

  • (ArgumentError)


13
14
15
16
17
# File 'lib/syncbox/store.rb', line 13

def initialize(store, options={})
  raise ArgumentError, "Store #{store} is not supported." unless STORES.fetch(store)
  class_name = STORES[store]
  @store = Object.const_get("Syncbox").const_get(class_name).new(options)
end

Instance Method Details

#add(file_path) ⇒ Object Also known as: modify

Add file to store.

Parameters:

  • file_path (String)

Returns:

  • a public (not authenticated) URL for the object



25
26
27
# File 'lib/syncbox/store.rb', line 25

def add(file_path)
  @store.upload(file_path)
end

#delete(file_path) ⇒ Object

delete file from store.

Parameters:

  • file_path (String)

Returns:

  • nil



35
36
37
# File 'lib/syncbox/store.rb', line 35

def delete(file_path)
  @store.delete(file_path)
end