Module: PMP::Configuration
- Extended by:
- ActiveSupport::Concern
- Included in:
- Client, CollectionDocument, Token
- Defined in:
- lib/pmp/configuration.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VALID_OPTIONS_KEYS =
[ :client_id, :client_secret, :oauth_token, :adapter, :endpoint, :user_agent, :debug ].freeze
- DEFAULT_CLIENT_ID =
this you need to get from pmp, not covered by this
nil
- DEFAULT_CLIENT_SECRET =
nil
- DEFAULT_ADAPTER =
Adapters are whatever Faraday supports - I like excon alot, so I’m defaulting it
:excon
- DEFAULT_ENDPOINT =
The api endpoint for YQL
'https://api.pmp.io/'.freeze
- DEFAULT_USER_AGENT =
The value sent in the http header for ‘User-Agent’ if none is set
"PMP Ruby Gem #{PMP::VERSION}".freeze
Instance Method Summary collapse
- #apply_configuration(opts = {}) ⇒ Object
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow for global setting of configuration options.
- #options ⇒ Object
-
#reset! ⇒ Object
Reset configuration options to their defaults.
Instance Method Details
#apply_configuration(opts = {}) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/pmp/configuration.rb', line 50 def apply_configuration(opts={}) reset! unless @options self. = .merge(opts) VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
#configure {|_self| ... } ⇒ Object
Convenience method to allow for global setting of configuration options
59 60 61 |
# File 'lib/pmp/configuration.rb', line 59 def configure yield self end |
#options ⇒ Object
75 76 77 78 79 |
# File 'lib/pmp/configuration.rb', line 75 def = {} VALID_OPTIONS_KEYS.each { |k| [k] = send(k) } end |
#reset! ⇒ Object
Reset configuration options to their defaults
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pmp/configuration.rb', line 64 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.debug = ENV['DEBUG'] self end |