Class: Status::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/status/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :github) ⇒ Request

Returns a new instance of Request.



37
38
39
40
41
# File 'lib/status/request.rb', line 37

def initialize(type=:github)
  @klass = {:github => GithubRequest, :ci => CiRequest}[type]
  @klass = @klass.new
  @site = RestClient::Resource.new(@klass.url, @klass.options, :headers => { :accept => :json, :content_type => :json })
end

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



36
37
38
# File 'lib/status/request.rb', line 36

def conn
  @conn
end

Instance Method Details

#get(path) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/status/request.rb', line 43

def get(path)
  begin
    MultiJson.decode @site[path].get
  rescue Exception => e
    raise NotFoundException.new(@klass, e)
  end
end

#post(path, data) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/status/request.rb', line 51

def post(path, data)
  begin
    MultiJson.decode @site[path].post(MultiJson.encode(data))
  rescue Exception => e
    raise NotFoundException.new(@klass, e)
  end
end