Class: Dragonfly::ScpDataStore::DataStore
- Inherits:
-
Object
- Object
- Dragonfly::ScpDataStore::DataStore
- Includes:
- Configurable
- Defined in:
- lib/dragonfly/scp_data_store.rb
Instance Method Summary collapse
- #destroy(uid) ⇒ Object
-
#initialize(options = {}) ⇒ DataStore
constructor
A new instance of DataStore.
- #retrieve(uid) ⇒ Object
- #store(temp_object, opts = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DataStore
18 19 20 21 22 23 24 |
# File 'lib/dragonfly/scp_data_store.rb', line 18 def initialize( = {}) self.host = [:host] self.username = [:username] self.password = [:password] self.folder = [:folder] self.base_url = [:base_url] end |
Instance Method Details
#destroy(uid) ⇒ Object
45 46 47 |
# File 'lib/dragonfly/scp_data_store.rb', line 45 def destroy(uid) raise DataNotFound end |
#retrieve(uid) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dragonfly/scp_data_store.rb', line 34 def retrieve(uid) uri = URI(base_url + uid) response = Net::HTTP.get_response(uri) if response.is_a? Net::HTTPSuccess [response.body, { }] else raise DataNotFound end end |
#store(temp_object, opts = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/dragonfly/scp_data_store.rb', line 26 def store(temp_object, opts={}) uid = generate_uid(temp_object.name || 'file') process_file(temp_object.file.path, uid) uid end |