Module: Slideshare::Configuration
- Included in:
- Slideshare
- Defined in:
- lib/slideshare/configuration.rb
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :adapter, :version, :api_key, :api_secret, :api_endpoint, :http_endpoint, :https_endpoint, :format, :user_agent ].freeze
- VALID_FROMATS =
[:xml].freeze
- DEFAULT_ADAPTER =
Faraday.default_adapter
- DEFAULT_VERSION =
"2".freeze
- DEFAULT_API_KEY =
nil
- DEFAULT_API_SECRET =
nil
- DEFAULT_API_ENDPOINT =
"https://www.slideshare.net/api/2/".freeze
- DEFAULT_FORMAT =
:xml
- DEFAULT_USER_AGENT =
"Slideshare Rub Gem #{Slideshare::VERSION}".freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configuration options to defaults.
Class Method Details
.extended(base) ⇒ Object
When this module is extended, set all configuration options to their default values
33 34 35 |
# File 'lib/slideshare/configuration.rb', line 33 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
38 39 40 |
# File 'lib/slideshare/configuration.rb', line 38 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
43 44 45 |
# File 'lib/slideshare/configuration.rb', line 43 def Hash[VALID_OPTIONS_KEYS.map {|key| [key, send(key)] }] end |
#reset ⇒ Object
Reset all configuration options to defaults
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/slideshare/configuration.rb', line 48 def reset self.adapter = DEFAULT_ADAPTER self.version = DEFAULT_VERSION self.api_key = DEFAULT_API_KEY self.api_secret = DEFAULT_API_SECRET self.api_endpoint = DEFAULT_API_ENDPOINT self.format = DEFAULT_FORMAT self.user_agent = DEFAULT_USER_AGENT self end |