lib/frenchy/request.rb in frenchy-0.0.1 vs lib/frenchy/request.rb in frenchy-0.0.2

- old
+ new

@@ -3,11 +3,11 @@ require "active_support/notifications" module Frenchy class Request # Create a new request with given parameters - def initialize(service, path, params={}, options={}) + def initialize(service, method, path, params={}, options={}) params.stringify_keys! path = path.dup path.scan(/(:[a-z0-9_+]+)/).flatten.uniq.each do |pat| k = pat.sub(":", "") @@ -20,19 +20,20 @@ params.delete(k) path.sub!(pat, v) end @service = service + @method = method @path = path @params = params @options = options end # Issue the request and return the value def value - ActiveSupport::Notifications.instrument("request.frenchy", {service: @service, path: @path, params: @params}.merge(@options)) do + ActiveSupport::Notifications.instrument("request.frenchy", {service: @service, method: @method, path: @path, params: @params}.merge(@options)) do client = Frenchy.find_service(@service) - client.get(@path, @params) + client.send(@method, @path, @params) end end end end