Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/route_translator/extensions/mapper.rb

Defined Under Namespace

Modules: Base

Instance Method Summary collapse

Instance Method Details

#add_route(action, options) ⇒ Object

:nodoc:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/route_translator/extensions/mapper.rb', line 13

def add_route(action, options) # :nodoc:
  path = path_for_action(action, options.delete(:path))

  if action.to_s =~ /^[\w\/]+$/
    options[:action] ||= action unless action.to_s.include?("/")
  else
    action = nil
  end

  if !options.fetch(:as, true)
    options.delete(:as)
  else
    options[:as] = name_for_action(options[:as], action)
  end

  mapping = Mapping.new(@set, @scope, path, options)
  app, conditions, requirements, defaults, as, anchor = mapping.to_route
  if @localized
    @set.add_localized_route(app, conditions, requirements, defaults, as, anchor)
  else
    @set.add_route(app, conditions, requirements, defaults, as, anchor)
  end
end

#localizedObject



6
7
8
9
10
# File 'lib/route_translator/extensions/mapper.rb', line 6

def localized
  @localized = true
  yield
  @localized = false
end