Sha256: 1522971abd9e3155fe72c7ce5554486d6ae2732ff1b63dae6f8165c8b87a6dea
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'active_support/concern' require 'kegbot_api/nouns/rest_noun' module KegbotApi # Rest noun that supports remote access via {#all} and {#find} class RemoteRestNoun < RestNoun # # Class Methods # class << self def list(response) if response.success? response.objects.map { |hash| self.new hash } else raise *response.raise_arguments end end def one(response) if response.success? self.new response.object else raise *response.raise_arguments end end def first all.first end def get(url, options = {}) uri = URI(url) Net::HTTP.start(uri.host, uri.port, :use_ssl => (uri.scheme == 'https')) do |http| http_response = http.request_get uri.request_uri case http_response when Net::HTTPRedirection raise NotImplementedError, "HTTP redirecting isn't supported" else RestResponse.new http_response end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kegbot_api-0.0.1 | lib/kegbot_api/nouns/remote_rest_noun.rb |