class APIHub::Resource
Public Class Methods
delete(action = '', params = {}, options = {})
click to toggle source
# File lib/apihub/resource.rb, line 54 def self.delete(action = '', params = {}, options = {}) request(uri(action), options.merge(method: :delete, params: params)) end
endpoint(value = nil)
click to toggle source
# File lib/apihub/resource.rb, line 5 def self.endpoint(value = nil) @endpoint = value if value return @endpoint if @endpoint superclass.respond_to?(:endpoint) ? superclass.endpoint : nil end
Also aliased as: endpoint=
get(action = '', params = {}, options = {})
click to toggle source
# File lib/apihub/resource.rb, line 42 def self.get(action = '', params = {}, options = {}) request(uri(action), options.merge(method: :get, params: params)) end
options(value = nil)
click to toggle source
# File lib/apihub/resource.rb, line 17 def self.options(value = nil) @options = value if value return @options if @options superclass.respond_to?(:options) ? superclass.options : {} end
Also aliased as: options=
path(value = nil)
click to toggle source
# File lib/apihub/resource.rb, line 11 def self.path(value = nil) @path = value if value return @path if @path superclass.respond_to?(:path) ? superclass.path : nil end
Also aliased as: path=
post(action = '', params = {}, options = {})
click to toggle source
# File lib/apihub/resource.rb, line 50 def self.post(action = '', params = {}, options = {}) request(uri(action), options.merge(method: :post, params: params)) end
put(action = '', params = {}, options = {})
click to toggle source
# File lib/apihub/resource.rb, line 46 def self.put(action = '', params = {}, options = {}) request(uri(action), options.merge(method: :put, params: params)) end
request(url, options = {})
click to toggle source
# File lib/apihub/resource.rb, line 58 def self.request(url, options = {}) options = Nestful::Helpers.deep_merge(self.options, options) self.new Nestful::Request.new( url, options ).execute end
uri(*parts)
click to toggle source
# File lib/apihub/resource.rb, line 33 def self.uri(*parts) # If an absolute URI already if (uri = parts.first) && uri.is_a?(URI) return uri if uri.host end URI.parse(Nestful::Helpers.to_path(url, *parts)) end
url()
click to toggle source
# File lib/apihub/resource.rb, line 29 def self.url URI.join(endpoint.to_s, path.to_s).to_s end