Class: CarrierWave::Storage::TT::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/storage/tt.rb

Instance Method Summary collapse

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(options={})
  @tt_host = options[:tt_host]
  @tt_port = options[:tt_port]
  @tt_domain = options[:tt_domain]
  @connection_options     = 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_clientObject



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