Sha256: 360011eb3bb74c15d7693436f0cac2c762c80b9beea14891bce0ce8a854f8c42

Contents?: true

Size: 932 Bytes

Versions: 23

Compression:

Stored size: 932 Bytes

Contents

require 'yao/plugins'
require 'faraday'
require 'faraday_middleware'
require 'yao/faraday_middlewares'

module Yao::Plugins
  class DefaultClientGenerator
    def call(f, token)
      f.request :accept, 'application/json'
      f.request :url_encoded

      if token
        f.request :os_token, token
      end

      f.request :read_only

      f.response :os_error_detector
      f.response :json, content_type: /\bjson$/

      if Yao.config.debug
        f.response :logger
        f.response :os_dumper
      end

      if Yao.config.debug_record_response
        f.response :os_response_recorder
      end

      f.adapter Faraday.default_adapter
    end

    Yao::Plugins.register(self, type: :client_generator)

    Yao.config.param :client_generator, :default do |v|
      raise("Invalid client_generator name %s.\nNote: name must be a Symbol" % v.inspect) unless Registry.instance[:client_generator][v]
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
yao-0.13.1 lib/yao/plugins/default_client_generator.rb
yao-0.13.0 lib/yao/plugins/default_client_generator.rb
yao-0.12.0 lib/yao/plugins/default_client_generator.rb
yao-0.11.3 lib/yao/plugins/default_client_generator.rb
yao-0.11.2 lib/yao/plugins/default_client_generator.rb
yao-0.11.1 lib/yao/plugins/default_client_generator.rb
yao-0.11.0 lib/yao/plugins/default_client_generator.rb
yao-0.10.1 lib/yao/plugins/default_client_generator.rb
yao-0.10.0 lib/yao/plugins/default_client_generator.rb
yao-0.9.1 lib/yao/plugins/default_client_generator.rb
yao-0.9.0 lib/yao/plugins/default_client_generator.rb
yao-0.8.0 lib/yao/plugins/default_client_generator.rb
yao-0.7.0 lib/yao/plugins/default_client_generator.rb
yao-0.6.3 lib/yao/plugins/default_client_generator.rb
yao-0.6.2 lib/yao/plugins/default_client_generator.rb
yao-0.6.1 lib/yao/plugins/default_client_generator.rb
yao-0.6.0 lib/yao/plugins/default_client_generator.rb
yao-0.5.0 lib/yao/plugins/default_client_generator.rb
yao-0.4.3 lib/yao/plugins/default_client_generator.rb
yao-0.4.2 lib/yao/plugins/default_client_generator.rb