Module: Ohanakapa::Default
- Defined in:
- lib/ohanakapa/default.rb
Overview
Default configuration options for Client
Constant Summary collapse
- API_ENDPOINT =
Default API endpoint
"http://ohana-api-demo.herokuapp.com/api".freeze
- USER_AGENT =
Default User Agent header string
"Ohanakapa Ruby Gem #{Ohanakapa::VERSION}".freeze
- MEDIA_TYPE =
Default media type
"application/vnd.ohanapi-v1+json"- RACK_BUILDER_CLASS =
In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder
defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
- MIDDLEWARE =
Default Faraday middleware stack
RACK_BUILDER_CLASS.new do |builder| builder.use Ohanakapa::Response::RaiseError builder.adapter Faraday.default_adapter end
Class Method Summary collapse
-
.api_endpoint ⇒ String
Default API endpoint from ENV or API_ENDPOINT.
-
.api_token ⇒ String
Default api token for Ohana API.
-
.auto_paginate ⇒ String
Default pagination preference from ENV.
-
.connection_options ⇒ Hash
Default options for Faraday::Connection.
-
.default_media_type ⇒ String
Default media type from ENV or MEDIA_TYPE.
-
.middleware ⇒ String
Default middleware stack for Faraday::Connection from MIDDLEWARE.
-
.options ⇒ Hash
Configuration options.
-
.per_page ⇒ Fixnum
Default pagination page size from ENV.
-
.proxy ⇒ String
Default proxy server URI for Faraday connection from ENV.
-
.user_agent ⇒ String
Default User-Agent header string from ENV or USER_AGENT.
Class Method Details
.api_endpoint ⇒ String
Default API endpoint from ENV or API_ENDPOINT
37 38 39 |
# File 'lib/ohanakapa/default.rb', line 37 def api_endpoint ENV['OHANA_API_ENDPOINT'] || API_ENDPOINT end |
.api_token ⇒ String
Default api token for Ohana API
87 88 89 |
# File 'lib/ohanakapa/default.rb', line 87 def api_token ENV['OHANAKAPA_API_TOKEN'] end |
.auto_paginate ⇒ String
Default pagination preference from ENV
43 44 45 |
# File 'lib/ohanakapa/default.rb', line 43 def auto_paginate ENV['OHANAKAPA_AUTO_PAGINATE'] end |
.connection_options ⇒ Hash
Default options for Faraday::Connection
57 58 59 60 61 62 63 64 |
# File 'lib/ohanakapa/default.rb', line 57 def { :headers => { :accept => default_media_type, :user_agent => user_agent } } end |
.default_media_type ⇒ String
Default media type from ENV or MEDIA_TYPE
68 69 70 |
# File 'lib/ohanakapa/default.rb', line 68 def default_media_type ENV['OHANAKAPA_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE end |
.middleware ⇒ String
Default middleware stack for Faraday::Connection from MIDDLEWARE
75 76 77 |
# File 'lib/ohanakapa/default.rb', line 75 def middleware MIDDLEWARE end |
.options ⇒ Hash
Configuration options
31 32 33 |
# File 'lib/ohanakapa/default.rb', line 31 def Hash[Ohanakapa::Configurable.keys.map{|key| [key, send(key)]}] end |
.per_page ⇒ Fixnum
Default pagination page size from ENV
49 50 51 52 53 |
# File 'lib/ohanakapa/default.rb', line 49 def per_page page_size = ENV['OCTOKIT_PER_PAGE'] page_size.to_i if page_size end |
.proxy ⇒ String
Default proxy server URI for Faraday connection from ENV
81 82 83 |
# File 'lib/ohanakapa/default.rb', line 81 def proxy ENV['OHANAKAPA_PROXY'] end |
.user_agent ⇒ String
Default User-Agent header string from ENV or USER_AGENT
93 94 95 |
# File 'lib/ohanakapa/default.rb', line 93 def user_agent ENV['OHANAKAPA_USER_AGENT'] || USER_AGENT end |