module DingBot::Configuration
Defines constants and methods related to configuration.
Constants
- DEFAULT_ENDPOINT
- DEFAULT_USER_AGENT
The user agent that will be sent to the API endpoint if none is set.
- VALID_OPTIONS_KEYS
An array of valid keys in the options hash when configuring a DingBot::API.
Public Class Methods
extended(base)
click to toggle source
Sets all configuration options to their default values when this module is extended.
# File lib/dingbot/configuration.rb, line 17 def self.extended(base) base.reset end
Public Instance Methods
configure() { |self| ... }
click to toggle source
Convenience method to allow configuration options to be set in a block.
# File lib/dingbot/configuration.rb, line 22 def configure yield self end
options()
click to toggle source
Creates a hash of options and their values.
# File lib/dingbot/configuration.rb, line 27 def options VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end
reset()
click to toggle source
Resets all configuration options to the defaults.
# File lib/dingbot/configuration.rb, line 34 def reset self.endpoint = ENV['DINGTALK_ENDPOINT'] || DEFAULT_ENDPOINT self.access_token = ENV['DINGTALK_ACCESS_TOKEN'] self.secret = ENV['DINGTALK_SECRET'] end