Module: Disqussion::Configuration
- Included in:
- Disqussion
- Defined in:
- lib/disqussion/configuration.rb
Overview
Defines constants and methods related to configuration
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a API
[ :adapter, :endpoint, :api_key, :api_secret, :developer, :container_id, :avatar_size, :color, :default_tab, :hide_avatars, :hide_mods, :num_items, :show_powered_by, :orientation, :format, :proxy, :user_agent].freeze
- VALID_FORMATS =
Note:
only json for now
An array of valid request/response formats
[:json].freeze
- DEFAULT_ADAPTER =
Note:
The default faraday adapter is Net::HTTP.
The adapter that will be used to connect if none is set
Faraday.default_adapter
- DEFAULT_API_KEY =
By default, don't set an application key
nil
- DEFAULT_API_SECRET =
By default, don't set an application secret
nil
- DEFAULT_API_VERSION =
Note:
This is configurable in case you want to use HTTP instead of HTTPS, specify a different API version, or use a Disqussion-compatible endpoint.
The endpoint that will be used to connect if none is set
'3.0'.freeze
- DEFAULT_ENDPOINT =
"https://disqus.com/api/#{DEFAULT_API_VERSION}/".freeze
- DEFAULT_FORMAT =
Note:
JSON is preferred over XML because it is more concise and faster to parse.
The response format appended to the path and sent in the 'Accept' header if none is set
:json
- DEFAULT_PROXY =
By default, don't use a proxy server
nil
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set
"Disqussion Ruby Gem #{Disqussion::VERSION}".freeze
- DEFAULT_DEVELOPER =
false
- DEFAULT_CONTAINER_ID =
'disqus_thread'
- DEFAULT_AVATAR_SIZE =
48
- DEFAULT_COLOR =
"grey"
- DEFAULT_DEFAULT_TAB =
"popular"
- DEFAULT_HIDE_AVATARS =
false
- DEFAULT_HIDE_MODS =
true
- DEFAULT_NUM_ITEMS =
15
- DEFAULT_SHOW_POWERED_BY =
true
- DEFAULT_ORIENTATION =
"horizontal"
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
79 80 81 |
# File 'lib/disqussion/configuration.rb', line 79 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
84 85 86 |
# File 'lib/disqussion/configuration.rb', line 84 def configure yield self end |
#options ⇒ Object
Create a hash of options and their values
89 90 91 92 93 |
# File 'lib/disqussion/configuration.rb', line 89 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k) } end |
#reset ⇒ Object
Reset all configuration options to defaults
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/disqussion/configuration.rb', line 96 def reset self.adapter = DEFAULT_ADAPTER self.endpoint = DEFAULT_ENDPOINT self.api_key = DEFAULT_API_KEY self.api_secret = DEFAULT_API_SECRET self.developer = DEFAULT_DEVELOPER self.container_id = DEFAULT_CONTAINER_ID self.avatar_size = DEFAULT_AVATAR_SIZE self.color = DEFAULT_COLOR self.default_tab = DEFAULT_DEFAULT_TAB self.hide_avatars = DEFAULT_HIDE_AVATARS self.hide_mods = DEFAULT_HIDE_MODS self.num_items = DEFAULT_NUM_ITEMS self.show_powered_by = DEFAULT_SHOW_POWERED_BY self.orientation = DEFAULT_ORIENTATION self.format = DEFAULT_FORMAT self.proxy = DEFAULT_PROXY self.user_agent = DEFAULT_USER_AGENT self end |