Method: Plezi::Base::Route#fits_params

Defined in:
lib/plezi/router/route.rb

#fits_params(path, request) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/plezi/router/route.rb', line 42

def fits_params(path, request)
   params = (Thread.current[@route_id] ||= {}).clear
   params.default_proc = Plezi.hash_proc_4symstr
   params.update request.params.to_h if request && request.params
   # puts "cutting: #{path[(@prefix_length)..-1] ? path[(@prefix_length + 1)..-1] : 'nil'}"
   pa = (path[@prefix_length..-1] || ''.freeze).split('/'.freeze)
   # puts "check param count: #{pa}"
   return false unless @params_range.include?(pa.length)
   @param_names.each do |key|
      next if pa[0].nil?
      self.class.qp.normalize_params(params, Plezi.try_utf8!(Rack::Utils.unescape(key)),
                                     Plezi.try_utf8!(Rack::Utils.unescape(pa.shift)), 100)
   end
   params['*'.freeze] = pa unless pa.empty?
   params
end