class Beerbelly::Client
Constants
- ALLOWED_OPTIONS
Attributes
configuration[RW]
Public Instance Methods
configure() { |configuration| ... }
click to toggle source
# File lib/beerbelly/client.rb, line 19 def configure yield configuration end
Protected Instance Methods
get_resource(path, options={})
click to toggle source
# File lib/beerbelly/client.rb, line 25 def get_resource(path, options={}) request_resource :get, path, options end
Private Instance Methods
request_resource(method, path, options={})
click to toggle source
# File lib/beerbelly/client.rb, line 31 def request_resource(method, path, options={}) resource = URI "#{configuration.base_url}#{path}.json" resource.query = URI.encode_www_form sanitize_options(options) response = HTTParty.send(method, resource.to_s) end
respond_with_resource(response, type)
click to toggle source
# File lib/beerbelly/client.rb, line 38 def respond_with_resource(response, type) Response.new response, type end
sanitize_options(options)
click to toggle source
# File lib/beerbelly/client.rb, line 47 def sanitize_options(options) options.merge!(configuration.to_hash).reject { |key, value| !ALLOWED_OPTIONS.include?(key.to_s) } end