Class: Hyperdrive::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperdrive/endpoint.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.envObject (readonly)

Returns the value of attribute env.



21
22
23
# File 'lib/hyperdrive/endpoint.rb', line 21

def env
  @env
end

.headersObject

Returns the value of attribute headers.



22
23
24
# File 'lib/hyperdrive/endpoint.rb', line 22

def headers
  @headers
end

.media_typeObject (readonly)

Returns the value of attribute media_type.



21
22
23
# File 'lib/hyperdrive/endpoint.rb', line 21

def media_type
  @media_type
end

.paramsObject (readonly)

Returns the value of attribute params.



21
22
23
# File 'lib/hyperdrive/endpoint.rb', line 21

def params
  @params
end

.requestObject (readonly)

Returns the value of attribute request.



21
22
23
# File 'lib/hyperdrive/endpoint.rb', line 21

def request
  @request
end

.resourceObject (readonly)

Returns the value of attribute resource.



21
22
23
# File 'lib/hyperdrive/endpoint.rb', line 21

def resource
  @resource
end

Class Method Details

.call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hyperdrive/endpoint.rb', line 6

def self.call(env)
  @env = env
  @request = Rack::Request.new(@env)
  @media_type = env['hyperdrive.media_type']
  @params = env['hyperdrive.params']
  @resource = env['hyperdrive.resource']
  @headers = Hyperdrive::Values.default_headers.dup
  @headers.merge!('Allow' => resource.allowed_methods.join(', '), 'Content-Type' => @media_type)
  before_response
  response.finish
end