Class: Rack::App::Router::Tree::Leaf

Inherits:
Hash
  • Object
show all
Defined in:
lib/rack/app/router/tree/leaf.rb

Constant Summary collapse

E =
Rack::App::Constants::ENV

Instance Method Summary collapse

Instance Method Details

#call_endpoint(env, current_path) ⇒ Object



19
20
21
22
# File 'lib/rack/app/router/tree/leaf.rb', line 19

def call_endpoint(env, current_path)
  app = self[current_path] || self[:ANY]
  (app && app.call(env)) || call_mount(env)
end

#call_mount(env) ⇒ Object



24
25
26
27
# File 'lib/rack/app/router/tree/leaf.rb', line 24

def call_mount(env)
  app = self[:MOUNT_POINT] || self[:APPLICATION]
  app && app.call(env)
end

#set(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rack/app/router/tree/leaf.rb', line 8

def set(env)
  case env.type
  when :APPLICATION
    self[env.type] = Rack::App::Router::Tree::Leaf::Mounted::Application.new(env.endpoint)
  when :MOUNT_POINT
    self[env.type] = Rack::App::Router::Tree::Leaf::Mounted.new(env.endpoint)
  else
    save_endpoint(env)
  end
end