Sha256: d39136f470f88a46f5e4622dcba2d00b1eda7ba10c0beb6321d64a9e5825f88f
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require 'missionhub/version' module MissionHub # Defines constants and methods related to configuration module Config # The API Key if none is set DEFAULT_CLIENT_SECRET = nil # The endpoint that will be used to connect if none is set DEFAULT_SITE = 'https://www.missionhub.com/apis/v3' # An array of valid keys in the options hash when configuring a {Twitter::Client} VALID_OPTIONS_KEYS = [ :client_secret, :site ] # When this module is extended, set all configuration options to their default values def self.extended(base) base.reset end VALID_OPTIONS_KEYS.each do |attr| define_method(attr) do Thread.current["mission_hub.#{attr}"] end define_method("#{attr}=") do |val| Thread.current["mission_hub.#{attr}"] = val end end # Convenience method to allow configuration options to be set in a block def config yield self Base.site = Thread.current["mission_hub.site"] self end # Create a hash of options and their values def options options = {} VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)} options end # Reset all configuration options to defaults def reset self.client_secret = DEFAULT_CLIENT_SECRET self.site = DEFAULT_SITE self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
MissionHub-2.1.0 | lib/missionhub/config.rb |