Class: CarrierWave::Storage::TT::Connection
- Inherits:
-
Object
- Object
- CarrierWave::Storage::TT::Connection
- Defined in:
- lib/carrierwave/storage/tt.rb
Instance Method Summary collapse
- #delete(path, headers = {}) ⇒ Object
- #escaped(path) ⇒ Object
- #get(path, headers = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #new_rest_client ⇒ Object
- #post(path, payload, headers = {}) ⇒ Object
- #put(path, payload, headers = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
16 17 18 19 20 21 22 23 |
# File 'lib/carrierwave/storage/tt.rb', line 16 def initialize(={}) @tt_host = [:tt_host] @tt_port = [:tt_port] @tt_domain = [:tt_domain] @connection_options = [:connection_options] || {} @@http ||= new_rest_client @@http = new_rest_client if @@http.url != "#{@tt_host}:#{@tt_port}" end |
Instance Method Details
#delete(path, headers = {}) ⇒ Object
37 38 39 |
# File 'lib/carrierwave/storage/tt.rb', line 37 def delete(path, headers = {}) @@http["#{escaped(path)}"].delete(headers) end |
#escaped(path) ⇒ Object
45 46 47 |
# File 'lib/carrierwave/storage/tt.rb', line 45 def escaped(path) CGI.escape(path) end |
#get(path, headers = {}) ⇒ Object
33 34 35 |
# File 'lib/carrierwave/storage/tt.rb', line 33 def get(path, headers = {}) @@http["#{escaped(path)}"].get(headers) end |
#new_rest_client ⇒ Object
25 26 27 |
# File 'lib/carrierwave/storage/tt.rb', line 25 def new_rest_client RestClient::Resource.new("#{@tt_host}:#{@tt_port}") end |
#post(path, payload, headers = {}) ⇒ Object
41 42 43 |
# File 'lib/carrierwave/storage/tt.rb', line 41 def post(path, payload, headers = {}) @@http["#{escaped(path)}"].post(payload, headers) end |
#put(path, payload, headers = {}) ⇒ Object
29 30 31 |
# File 'lib/carrierwave/storage/tt.rb', line 29 def put(path, payload, headers = {}) @@http["#{escaped(path)}"].put(payload, headers) end |