Class: BadgevilleBerlin::Config

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/badgeville_berlin/config.rb

Constant Summary

Constants inherited from BaseResource

BaseResource::COMPLEX_ATTRIBUTES

Class Method Summary collapse

Methods inherited from BaseResource

#customize_keys_for_request, #encode, #errors, #initialize, #load, #load_remote_errors, #sanitize_request

Constructor Details

This class inherits a constructor from BadgevilleBerlin::BaseResource

Class Method Details

.conf(options = {}) ⇒ Object

This class method configures the BaseResource members: format, site and prefix.

Parameters:

  • options (Hash) (defaults to: {})

    the options hash which holds values for the keys ‘:api_key` and `:host_name`



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/badgeville_berlin/config.rb', line 10

def conf ( options = {} )

  BaseResource.format = :badgeville_berlin_json

  if options[:host_name] == nil || options[:host_name].empty?
      raise ArgumentError.new("Please enter the URL for the Badgeville host where you want to make your request ( e.g. :host_name  => 'http://www.example.com' ).")
  else
    BaseResource.site = options[:host_name]
    if options[:host_name].split("://")[1] == nil
      raise ArgumentError.new("Please include the scheme for the request host ( e.g. http:// ).")
    end
  end

  if options[:api_key] == nil || options[:api_key].empty?
    raise ArgumentError.new("Please enter a Badgeville API Key ( e.g. :api_key  => '[your Badgeville API Key]' ).")
  else
    @api_key = options[:api_key]
  end


  # set a path that goes between the URL and the resource
  BaseResource.prefix = "/api/berlin/#@api_key/"
end