Class: OpenSecrets::Base
- Inherits:
-
Object
- Object
- OpenSecrets::Base
- Includes:
- HTTParty
- Defined in:
- lib/opensecrets.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(apikey = nil) ⇒ Base
constructor
OpenSecrets Base constructor.
Constructor Details
#initialize(apikey = nil) ⇒ Base
OpenSecrets Base constructor. All OpenSecrets API classes inherit from this one which provides the common initialization function. For convenience you can skip providing an ‘apikey’ to the constructor if you instead export a OPENSECRETS_API_KEY environment variable which is set to the value of your API key.
19 20 21 22 23 |
# File 'lib/opensecrets.rb', line 19 def initialize(apikey = nil) key = apikey ||= ENV['OPENSECRETS_API_KEY'] raise ArgumentError, 'You must provide an API Key' if key.nil? || key.empty? self.class.default_params :apikey => key end |