Class: Hipbot::Http::Request
- Inherits:
-
Struct
- Object
- Struct
- Hipbot::Http::Request
- Defined in:
- lib/hipbot/helpers/http.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'accept-encoding' => 'gzip, compressed' }.freeze
- CONNECTION_SETTINGS =
{ connect_timeout: 5, inactivity_timeout: 10 }.freeze
- ERROR_CALLBACK =
->(error){ Hipbot.logger.error(error) }
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #call(&success_block) ⇒ Object
-
#initialize(*args) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(*args) ⇒ Request
Returns a new instance of Request.
9 10 11 12 13 14 15 |
# File 'lib/hipbot/helpers/http.rb', line 9 def initialize *args super self.params ||= {} self.params = params.has_key?(:query) ? params : { query: params } self.params = { head: DEFAULT_HEADERS }.merge(params) Hipbot.logger.info("HTTP-REQUEST: #{url} #{params}") end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method
4 5 6 |
# File 'lib/hipbot/helpers/http.rb', line 4 def method @method end |
#params ⇒ Object
Returns the value of attribute params
4 5 6 |
# File 'lib/hipbot/helpers/http.rb', line 4 def params @params end |
#url ⇒ Object
Returns the value of attribute url
4 5 6 |
# File 'lib/hipbot/helpers/http.rb', line 4 def url @url end |
Instance Method Details
#call(&success_block) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/hipbot/helpers/http.rb', line 17 def call &success_block http.errback(&ERROR_CALLBACK) http.callback do success(&success_block) end unless success_block.nil? end |