class Glomper::Request
Public Class Methods
new(client, api, *args, &block)
click to toggle source
# File lib/glomper/request.rb, line 4 def initialize(client, api, *args, &block) @client = client @api = api @id = args.first @method = 'post' end
Public Instance Methods
build_url(meth)
click to toggle source
# File lib/glomper/request.rb, line 27 def build_url meth url = '/api/%s/' % @api[:url] if @api[:methods][meth] url += meth.to_s else url += '%s/%s' % [@id?@id:'self', meth] end url end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/glomper/request.rb, line 11 def method_missing(meth, *args, &block) if @api[:methods][meth] || @api[:actions][meth] || @api[:aspects][meth] @method = 'get' if @api[:aspects][meth] send_request(meth, *args, &block) else super end end
send_request(meth, *args, &block)
click to toggle source
# File lib/glomper/request.rb, line 20 def send_request(meth, *args, &block) response = @client.connection.send(@method) do |req| req.url build_url(meth), *args end @client.return_error_or_body(response, response.body.response) end