module Roda::RodaPlugins::ParamsCapturing::RequestMethods
Public Instance Methods
Source
# File lib/roda/plugins/params_capturing.rb, line 60 def params ret = super ret['captures'] ||= [] ret end
Lazily initialize captures entry when params is called.
Calls superclass method
Private Instance Methods
Source
# File lib/roda/plugins/params_capturing.rb, line 70 def _match_string(str) cap_len = @captures.length if (ret = super) && (pc = @_params_captures) && (cap_len != @captures.length) # Handle use with placeholder_string_matchers plugin pc.concat(str.scan(/(?<=:)\w+/)) end ret end
Add the capture names from this string to list of param capture names if param capturing.
Calls superclass method
Source
# File lib/roda/plugins/params_capturing.rb, line 82 def _match_symbol(sym) if pc = @_params_captures pc << sym.to_s end super end
Add the symbol to the list of param capture names if param capturing.
Calls superclass method
Source
# File lib/roda/plugins/params_capturing.rb, line 93 def if_match(args) params = self.params if args.all?{|x| x.is_a?(String) || x.is_a?(Symbol)} pc = @_params_captures = [] end super do |*a| if pc @_params_captures = nil pc.zip(a).each do |k,v| params[k] = v end end params['captures'].concat(a) yield(*a) end end
If all arguments are strings or symbols, turn on param capturing during the matching, but turn it back off before yielding to the block. Add any captures to the params based on the param capture names added by the matchers.
Calls superclass method