Class: Rack::Mount::Mappers::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/mount/mappers/simple.rb

Instance Method Summary collapse

Constructor Details

#initialize(set) ⇒ Simple

Returns a new instance of Simple.



13
14
15
# File 'lib/rack/mount/mappers/simple.rb', line 13

def initialize(set)
  @set = set
end

Instance Method Details

#map(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rack/mount/mappers/simple.rb', line 17

def map(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}

  app = options[:to]
  path = args[0]
  method = args[1]
  defaults = options[:with]

  requirements = options[:conditions] || {}
  requirements.each { |k,v| requirements[k] = v.to_s unless v.is_a?(Regexp) }

  if path.is_a?(String)
    path = Utils.convert_segment_string_to_regexp(path, requirements, %w( / . ? ))
  end
  conditions = { :method => method, :path => path }
  @set.add_route(app, conditions, defaults)
end