Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_mobile/mobile_dispatch/action_dispatch.rb

Instance Method Summary collapse

Instance Method Details

#match(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rails_mobile/mobile_dispatch/action_dispatch.rb', line 6

def match(*args)
  options = nil
  path = nil
  if args.size == 1 && args.last.is_a?(Hash)
    options  = args.pop
    path, to = options.find { |name, value| name.is_a?(String) }
    options.merge!(:to => to).delete(path)

  else
    path = args.shift
    options  = args.pop

  end
  if options.nil?
    super path
  else
    if options.fetch(:classifier,nil).nil?
      super path,options
    else
      
      mobile_only = options.fetch(:mobile_only,false)
      
      if mobile_only 
        options.update({:constraints => MobileMatcher.new})
      end
      
      options.update({:to => mobile_dispatch(path,options) })
      super path.gsub(/\$/,''), options
    end
  end
  
end