Class: Rack::App::Router::Tree::Branch

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

Instance Method Summary collapse

Instance Method Details

#call(env, current, *path_info_parts) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rack/app/router/tree/branch.rb', line 12

def call(env, current, *path_info_parts)
  if path_info_parts.empty?
    try_leaf { |l| l.call_endpoint(env, current) || l.call_mount(env)  }
  else
    next_branch = self[current] || self[:ANY]
    resp = next_branch && next_branch.call(env, *path_info_parts)
    resp || try_leaf { |l| l.call_mount(env) }
  end
end

#set(env) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/rack/app/router/tree/branch.rb', line 4

def set(env)
  if env.branch?
    branch_for(env.save_key).set(env.next)
  else
    leaf.set(env)
  end
end