Class: Dispatcher

Inherits:
Object
  • Object
show all
Includes:
ActionDispatch::Routing::UrlFor
Defined in:
app/rack/dispatcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'app/rack/dispatcher.rb', line 5

def env
  @env
end

Class Method Details

.call(env) ⇒ Object



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

def self.call(env)
  new(env).dispatch
end

Instance Method Details

#dispatchObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/rack/dispatcher.rb', line 7

def dispatch
  # find permalink, raising error if none found
  if permalink
    # mutate env to include params for delegate route
    params.merge! content_route

    # setup and delegate to the matched route
    delegate.action(content_route[:action]).call(env)
  else
    # no slug matched, abstain from handling request
    [404, {"X-Cascade" => "pass"}, ["no such slug exists"]]
  end

end