Module: Granite::Routing::Mapping

Defined in:
lib/granite/routing/mapping.rb

Instance Method Summary collapse

Instance Method Details

#appObject

Override the ‘ActionDispatch::Routing::Mapper::Mapping#app` method to be able to mount custom Dispatcher objects. Otherwise, the only way to point a dispatcher to business actions is to mount it as a Rack app but we want to use regular Rails flow.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/granite/routing/mapping.rb', line 8

def app(*)
  if to.is_a?(Granite::Dispatcher)
    ActionDispatch::Routing::Mapper::Constraints.new(
      to,
      to.constraints,
      ActionDispatch::Routing::Mapper::Constraints::SERVE
    )
  else
    super
  end
end