Class: Hateoas::MediaType::Request

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hateoas.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, media_type) ⇒ Request

Returns a new instance of Request.



41
42
43
44
# File 'lib/hateoas.rb', line 41

def initialize(url, media_type)
  @uri = URI(url)
  @media_type = media_type
end

Instance Method Details

#getObject



46
47
48
49
50
51
# File 'lib/hateoas.rb', line 46

def get
  req = Net::HTTP::Get.new(request_uri)
  req['Accept'] = @media_type

  Net::HTTP.start(hostname, port) {|http| http.request(req) }.body
end