Module: Musashi::Connection
- Included in:
- Retriever::Base
- Defined in:
- lib/musashi/connection.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#endpoint ⇒ Object
5 6 7 8 |
# File 'lib/musashi/connection.rb', line 5 def endpoint raise 'Undefined endpoint' if @endpoint.nil? @endpoint end |
#format ⇒ Object
11 12 13 |
# File 'lib/musashi/connection.rb', line 11 def format @format ||= :json end |
Instance Method Details
#accept ⇒ Object
15 16 17 |
# File 'lib/musashi/connection.rb', line 15 def accept @accept ||= "application/#{format.to_s}" end |
#connection ⇒ Object
46 47 48 |
# File 'lib/musashi/connection.rb', line 46 def connection @connection ||= ::Faraday.new() end |
#options ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/musashi/connection.rb', line 19 def return @options if @options builder = ::Faraday::Builder.new builder.use ::Faraday::Request::Multipart builder.use ::Faraday::Request::UrlEncoded builder.use ::Faraday::Response::RaiseHttp4xx case format.to_s.downcase when 'json' builder.use ::Faraday::Response::Mashify builder.use ::Faraday::Response::ParseJson when 'xml' builder.use ::Faraday::Response::Mashify builder.use ::Faraday::Response::ParseXml end builder.use ::Faraday::Response::RaiseHttp5xx builder.adapter :net_http @options = { :headers => { 'Accept' => accept, 'User-Agent' => "Musashi Gem #{::Musashi::VERSION}" }, :url => endpoint, :ssl => {:verify => false}, :builder => builder } end |