Class: Strobe::Connection::Request
- Inherits:
-
Object
- Object
- Strobe::Connection::Request
- Defined in:
- lib/strobe/connection.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(connection, method, path, body, headers) ⇒ Request
constructor
A new instance of Request.
- #port ⇒ Object
- #send ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(connection, method, path, body, headers) ⇒ Request
Returns a new instance of Request.
144 145 146 147 |
# File 'lib/strobe/connection.rb', line 144 def initialize(connection, method, path, body, headers) @connection, @path, @body, @headers = connection, path, body, headers @method = method end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
142 143 144 |
# File 'lib/strobe/connection.rb', line 142 def body @body end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
142 143 144 |
# File 'lib/strobe/connection.rb', line 142 def connection @connection end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
142 143 144 |
# File 'lib/strobe/connection.rb', line 142 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
142 143 144 |
# File 'lib/strobe/connection.rb', line 142 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
142 143 144 |
# File 'lib/strobe/connection.rb', line 142 def path @path end |
Instance Method Details
#host ⇒ Object
149 |
# File 'lib/strobe/connection.rb', line 149 def host; connection.host end |
#port ⇒ Object
150 |
# File 'lib/strobe/connection.rb', line 150 def port; connection.port end |
#send ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/strobe/connection.rb', line 152 def send http = build_http request = Net::HTTPGenericRequest.new(method, !!body, true, path, headers) body = self.body if body.respond_to?(:read) request.body_stream = body body = nil end http.request(request, body) end |
#to_hash ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/strobe/connection.rb', line 165 def to_hash { :method => method, :path => path, :body => body, :headers => headers } end |