module PMP::Configuration
Constants
- DEFAULT_ADAPTER
Adapters are whatever Faraday supports - I like excon alot, so I'm defaulting it
- DEFAULT_CLIENT_ID
this you need to get from pmp, not covered by this
- DEFAULT_CLIENT_SECRET
- DEFAULT_ENDPOINT
The api endpoint for YQL
- DEFAULT_TOKEN_TYPE
- DEFAULT_USER_AGENT
The value sent in the http header for 'User-Agent' if none is set
- VALID_OPTIONS_KEYS
Public Class Methods
extended(base)
click to toggle source
# File lib/pmp/configuration.rb, line 89 def self.extended(base) base.reset! end
Public Instance Methods
apply_configuration(opts={})
click to toggle source
# File lib/pmp/configuration.rb, line 60 def apply_configuration(opts={}) options = PMP.options.merge(opts) if options[:endpoint] && options[:endpoint][-1] != '/' options[:endpoint] += '/' end self.current_options = options VALID_OPTIONS_KEYS.each do |key| send("#{key}=", options[key]) end end
configure() { |self| ... }
click to toggle source
Convenience method to allow for global setting of configuration options
# File lib/pmp/configuration.rb, line 72 def configure yield self end
options()
click to toggle source
# File lib/pmp/configuration.rb, line 54 def options options = {} VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) } options end
reset!()
click to toggle source
Reset configuration options to their defaults
# File lib/pmp/configuration.rb, line 77 def reset! @options = {} self.client_id = DEFAULT_CLIENT_ID self.client_secret = DEFAULT_CLIENT_SECRET self.adapter = DEFAULT_ADAPTER self.endpoint = DEFAULT_ENDPOINT self.user_agent = DEFAULT_USER_AGENT self.token_type = DEFAULT_TOKEN_TYPE self.debug = ENV['DEBUG'] self end