lib/olaf/controller.rb
# We override process_route to not blindly revert @params at the end, but
# just remove the 'splat' and 'captures' values from params, or else in
# some cases, our changes to params in before blocks get overwritten
# TODO: find better way? File bug against Sinatra?
We override process_route to not blindly revert @params at the end, but
just remove the 'splat' and 'captures' values from params, or else in
some cases, our changes to params in before blocks get overwritten
TODO: find better way.
We override process_route to not blindly revert @params at the end but just remove the ' splat ' and ' captures ' values from params or else in some cases our changes to params in before blocks get overwritten TODO : find better way .
def process_route(pattern, keys, conditions, block = nil, values = [])
      route = @request.path_info
      route = '/' if route.empty? and not settings.empty_path_info?
      return unless match = pattern.match(route)
      values += match.captures.to_a.map { |v| force_encoding URI.unescape(v) if v }
      if values.any?
        original, @params = params, params.merge('splat' => [], 'captures' => values)
        keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
      end
      catch(:pass) do
        conditions.each { |c| throw :pass if c.bind(self).call == false }
        block ? block[self, values] : yield(self, values)
      end
    ensure
      @params.delete('splat')
      @params.delete('captures')
    end
def process_route ( pattern , keys , conditions , block = nil , values = [ ] ) route = @request . path_info route = '/' if route . empty? and not settings . empty_path_info? return unless match = pattern . match ( route ) values += match . captures . to_a . map { | v | force_encoding URI . unescape ( v ) if v } if values . any? original , @params = params , params . merge ( 'splat' => [ ] , 'captures' => values ) keys . zip ( values ) { | k , v | Array === @params [ k ] ? @params [ k ] << v : @params [ k ] = v if v } end catch ( :pass ) do conditions . each { | c | throw :pass if c . bind ( self ) . call == false } block ? block [ self , values ] : yield ( self , values ) end ensure @params . delete ( 'splat' ) @params . delete ( 'captures' ) end
We override process_route to not blindly revert @params at the end, but
just remove the 'splat' and 'captures' values from params, or else in
some cases, our changes to params in before blocks get overwritten
TODO: find better way?
We override process_route to not blindly revert @params at the end but just remove the ' splat ' and ' captures ' values from params or else in some cases our changes to params in before blocks get overwritten TODO : find better way?
# Original: # @params = original if original
pattern
keys
conditions
block
values