Module: ServiceShooter

Defined in:
lib/service_shooter.rb,
lib/service_shooter/railtie.rb,
lib/service_shooter/version.rb

Defined Under Namespace

Classes: Railtie, Response, ResponseMapper

Constant Summary collapse

VERSION =
"0.1.5"

Class Method Summary collapse

Class Method Details

.delete(url, params = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/service_shooter.rb', line 51

def self.delete(url, params={})
  begin
    flat_params = params.collect{|k,v| "#{k}=#{v}"}.join("&")
    response = JSON.parse(RestClient.delete(url+(params.present? ? "?"+flat_params : "")))
  rescue => e
    Rails.logger.fatal e
  end
  response ||= {}
  Response.new(response)
end

.get(url, params = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/service_shooter.rb', line 30

def self.get(url, params={})
  begin
    flat_params = params.collect{|k,v| "#{k}=#{v}"}.join("&")
    response = JSON.parse(RestClient.get(url+(params.present? ? "?"+flat_params : "")))
  rescue => e
    Rails.logger.fatal e
  end
  response ||= {}
  Response.new(response)
end

.post(url, params = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/service_shooter.rb', line 41

def self.post(url, params={})
  begin
    response = JSON.parse(RestClient.post(url, params))
  rescue => e
    Rails.logger.fatal e
  end
  response ||= {}
  Response.new(response)
end