Class: Saorin::Client::Faraday
- Inherits:
-
Object
- Object
- Saorin::Client::Faraday
- Includes:
- Base
- Defined in:
- lib/saorin/client/faraday.rb
Constant Summary collapse
- CONTENT_TYPE =
'application/json'.freeze
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Attributes included from Base
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Faraday
constructor
A new instance of Faraday.
- #send_request(content) ⇒ Object
Methods included from Base
#apply, #batch, #call, #notify
Methods included from Formatter
#default_formatter, #formatter
Methods included from Base::UUID
Constructor Details
#initialize(options = {}, &block) ⇒ Faraday
Returns a new instance of Faraday.
12 13 14 15 16 17 18 19 20 |
# File 'lib/saorin/client/faraday.rb', line 12 def initialize( = {}, &block) super @connection = ::Faraday::Connection.new() do |builder| builder.adapter ::Faraday.default_adapter builder.response :raise_error block.call builder if block end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/saorin/client/faraday.rb', line 10 def connection @connection end |
Instance Method Details
#send_request(content) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/saorin/client/faraday.rb', line 22 def send_request(content) response = @connection.post do |req| req.headers[:content_type] = CONTENT_TYPE req.body = content end response.body end |