Method: Megam::API#initialize
- Defined in:
- lib/megam/api.rb
#initialize(options = {}) ⇒ API
It is assumed that every API call will use an API_KEY/email. This ensures validity of the person really the same guy on who he claims. 3 levels of options exits
-
The global OPTIONS as available inside the API (OPTIONS)
-
The options as passed via the instantiation of API will override global options. The ones that are passed are :email and :api_key and will
be merged into a class variable @options
-
Upon merge of the options, the api_key, email as available in the @options is deleted.
140 141 142 143 144 145 |
# File 'lib/megam/api.rb', line 140 def initialize(={}) @options = OPTIONS.merge() @api_key = @options.delete(:api_key) || ENV['MEGAM_API_KEY'] @email = @options.delete(:email) raise ArgumentError, "You must specify [:email, :api_key]" if @email.nil? || @api_key.nil? end |