Class: Slash::Connection
- Inherits:
-
Object
- Object
- Slash::Connection
- Extended by:
- Forwardable
- Defined in:
- lib/slash/connection.rb
Direct Known Subclasses
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#delete(uri, options = {}, &block) ⇒ Object
Execute a DELETE request (see HTTP protocol documentation if unfamiliar).
-
#get(uri, options = {}, &block) ⇒ Object
Execute a GET request.
-
#head(uri, options = {}, &block) ⇒ Object
Execute a HEAD request.
-
#post(uri, options = {}, &block) ⇒ Object
Execute a POST request.
-
#put(uri, options = {}, &block) ⇒ Object
Execute a PUT request.
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
#proxy ⇒ Object
Returns the value of attribute proxy.
13 14 15 |
# File 'lib/slash/connection.rb', line 13 def proxy @proxy end |
#timeout ⇒ Object
Returns the value of attribute timeout.
13 14 15 |
# File 'lib/slash/connection.rb', line 13 def timeout @timeout end |
Class Method Details
.create_default ⇒ Object
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, = {}, &block) request(:delete, uri, , &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, = {}, &block) request(:get, uri, , &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, = {}, &block) request(:head, uri, , &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, = {}, &block) request(:post, uri, , &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, = {}, &block) request(:put, uri, , &block) end |