Class: Gecko::Http
- Inherits:
-
Object
- Object
- Gecko::Http
- Defined in:
- lib/gecko/http.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #encode_body(body) ⇒ Object
- #headers ⇒ Object
-
#initialize(*args) ⇒ Http
constructor
A new instance of Http.
- #post(url, body, &request_block) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Http
Returns a new instance of Http.
5 6 7 8 9 10 11 12 13 |
# File 'lib/gecko/http.rb', line 5 def initialize(*args) @connection = Faraday.new(*args) do |connection| connection.response :multi_json, :symbolize_keys => true Gecko.config.connection_builder.call(connection) if Gecko.config.connection_builder.respond_to?(:call) yield connection if block_given? connection.adapter Faraday.default_adapter if connection.builder.handlers.none? { |handler| handler.klass < Faraday::Adapter } end self end |
Instance Method Details
#encode_body(body) ⇒ Object
22 23 24 |
# File 'lib/gecko/http.rb', line 22 def encode_body(body) MultiJson.encode(body) end |