Class: Rack::App::Endpoint

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rack/app/endpoint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties) ⇒ Endpoint

Returns a new instance of Endpoint.



14
15
16
# File 'lib/rack/app/endpoint.rb', line 14

def initialize(properties)
  @config = Rack::App::Endpoint::Config.new(properties)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/rack/app/endpoint.rb', line 12

def config
  @config
end

Instance Method Details

#call(env) ⇒ Object



26
27
28
# File 'lib/rack/app/endpoint.rb', line 26

def call(env)
  to_app.call(env)
end

#fork(differences_in_properties) ⇒ Object



18
19
20
# File 'lib/rack/app/endpoint.rb', line 18

def fork(differences_in_properties)
  self.class.new(self.properties.merge(differences_in_properties))
end

#propertiesObject



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

def properties
  @config.to_hash
end

#rack_app?Boolean

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/rack/app/endpoint.rb', line 37

def rack_app?
  !!@config.app_class
rescue
  false
end

#to_appObject



30
31
32
33
34
35
# File 'lib/rack/app/endpoint.rb', line 30

def to_app
  # TODO: fix this to cache it, but to that you need to resolve the problem when middlewares added,
  # old endpoints are not refreshed by the middleware configs
  # router.reset must be checked
  self.class::Builder.new(@config).to_app
end