Module: TedApi::Configuration
- Included in:
- TedApi
- Defined in:
- lib/ted_api/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :adapter, :api_version, :api_endpoint, :web_endpoint, :api_key, :response_format, :user_agent].freeze
- DEFAULT_ADAPTER =
Faraday.default_adapter
- DEFAULT_API_VERSION =
'v1'
- DEFAULT_API_ENDPOINT =
'https://api.ted.com/'
- DEFAULT_WEB_ENDPOINT =
'https://ted.com/'
- DEFAULT_USER_AGENT =
"ted-api ruby gem #{TedApi::VERSION}".freeze
- DEFAULT_RESPONSE_FORMAT =
'json'
Class Method Summary collapse
Instance Method Summary collapse
- #api_endpoint=(value) ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #options ⇒ Object
- #reset ⇒ Object
- #web_endpoint=(value) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
24 25 26 |
# File 'lib/ted_api/configuration.rb', line 24 def self.extended(base) base.reset end |
Instance Method Details
#api_endpoint=(value) ⇒ Object
36 37 38 |
# File 'lib/ted_api/configuration.rb', line 36 def api_endpoint=(value) @api_endpoint = File.join(value, "") end |
#configure {|_self| ... } ⇒ Object
28 29 30 |
# File 'lib/ted_api/configuration.rb', line 28 def configure yield self end |
#options ⇒ Object
32 33 34 |
# File 'lib/ted_api/configuration.rb', line 32 def VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) } end |
#reset ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/ted_api/configuration.rb', line 44 def reset self.adapter = DEFAULT_ADAPTER self.api_version = DEFAULT_API_VERSION self.api_endpoint = DEFAULT_API_ENDPOINT self.web_endpoint = DEFAULT_WEB_ENDPOINT self.api_key = nil self.response_format = DEFAULT_RESPONSE_FORMAT self.user_agent = DEFAULT_USER_AGENT end |
#web_endpoint=(value) ⇒ Object
40 41 42 |
# File 'lib/ted_api/configuration.rb', line 40 def web_endpoint=(value) @web_endpoint = File.join(value, "") end |