Class: Slash::Connection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/slash/connection.rb

Direct Known Subclasses

NetHttpConnection, TyphoeusConnection

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.default(&block) ⇒ Object



101
102
103
104
# File 'lib/slash/connection.rb', line 101

def default(&block)
  @default = block if block_given?
  @default
end

Instance Attribute Details

#proxyObject

Returns the value of attribute proxy.



13
14
15
# File 'lib/slash/connection.rb', line 13

def proxy
  @proxy
end

#timeoutObject

Returns the value of attribute timeout.



13
14
15
# File 'lib/slash/connection.rb', line 13

def timeout
  @timeout
end

Class Method Details

.create_defaultObject



106
107
108
109
110
111
112
# File 'lib/slash/connection.rb', line 106

def create_default
  if @default.respond_to?(:new)
    return @default.new
  else
    return @default.call
  end
end

Instance Method Details

#delete(uri, options = {}, &block) ⇒ Object

Execute a DELETE request (see HTTP protocol documentation if unfamiliar). Used to delete resources.



23
24
25
# File 'lib/slash/connection.rb', line 23

def delete(uri, options = {}, &block)
  request(:delete, uri, options, &block)
end

#get(uri, options = {}, &block) ⇒ Object

Execute a GET request. Used to get (find) resources.



17
18
19
# File 'lib/slash/connection.rb', line 17

def get(uri, options = {}, &block)
  request(:get, uri, options, &block)
end

#head(uri, options = {}, &block) ⇒ Object

Execute a HEAD request. Used to obtain meta-information about resources, such as whether they exist and their size (via response headers).



41
42
43
# File 'lib/slash/connection.rb', line 41

def head(uri, options = {}, &block)
  request(:head, uri, options, &block)
end

#post(uri, options = {}, &block) ⇒ Object

Execute a POST request. Used to create new resources.



35
36
37
# File 'lib/slash/connection.rb', line 35

def post(uri, options = {}, &block)
  request(:post, uri, options, &block)
end

#put(uri, options = {}, &block) ⇒ Object

Execute a PUT request. Used to update resources.



29
30
31
# File 'lib/slash/connection.rb', line 29

def put(uri, options = {}, &block)
  request(:put, uri, options, &block)
end