Class: CarrierWave::Storage::Riak::Connection
- Inherits:
-
Object
- Object
- CarrierWave::Storage::Riak::Connection
- Defined in:
- lib/carrierwave/storage/riak.rb
Instance Method Summary collapse
- #delete(bucket, key) ⇒ Object
- #escaped(path) ⇒ Object
- #get(bucket, key) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, payload, headers = {}) ⇒ Object
- #store(bucket, key, payload, headers = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
19 20 21 |
# File 'lib/carrierwave/storage/riak.rb', line 19 def initialize(={}) @client = ::Riak::Client.new() end |
Instance Method Details
#delete(bucket, key) ⇒ Object
36 37 38 39 |
# File 'lib/carrierwave/storage/riak.rb', line 36 def delete(bucket, key) bucket = @client.bucket(bucket) bucket.delete(key) end |
#escaped(path) ⇒ Object
45 46 47 |
# File 'lib/carrierwave/storage/riak.rb', line 45 def escaped(path) CGI.escape(path) end |
#get(bucket, key) ⇒ Object
31 32 33 34 |
# File 'lib/carrierwave/storage/riak.rb', line 31 def get(bucket, key) bucket = @client.bucket(bucket) bucket.get(key) end |
#post(path, payload, headers = {}) ⇒ Object
41 42 43 |
# File 'lib/carrierwave/storage/riak.rb', line 41 def post(path, payload, headers = {}) @http["#{escaped(path)}"].post(payload, headers) end |
#store(bucket, key, payload, headers = {}) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/carrierwave/storage/riak.rb', line 23 def store(bucket, key, payload, headers = {}) bucket = @client.bucket(bucket) robject = ::Riak::RObject.new(bucket, key) robject.content_type = headers[:content_type] robject.raw_data = payload robject.store end |