Class: FocusedController::RouteMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/focused_controller/route_mapper.rb

Overview

The monkey-patching in this file makes me sadface but I can’t see another way ;(

Instance Method Summary collapse

Constructor Details

#initialize(scope, options) ⇒ RouteMapper

Returns a new instance of RouteMapper.



8
9
10
# File 'lib/focused_controller/route_mapper.rb', line 8

def initialize(scope, options)
  @scope, @options = scope, options
end

Instance Method Details

#optionsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/focused_controller/route_mapper.rb', line 12

def options
  options = @options.dup

  if to = to_option
    options[:to]         = FocusedController::Route.new(to)

    # This causes rails to spit out a bit of extra useful information in the case
    # of a routing error. The :action option is also necessary for the routing to
    # work on Rails <= 3.1.
    options[:action]     = FocusedController.action_name
    options[:controller] = to.underscore
  end

  options
end