Skip to content

Instantly share code, notes, and snippets.

@dyoder
Created September 14, 2008 07:07
Show Gist options
  • Save dyoder/10717 to your computer and use it in GitHub Desktop.
Save dyoder/10717 to your computer and use it in GitHub Desktop.
def call( request )
capture = {}
path = extract_path( request )
capture if @pattern.all? do | want |
case want
when true then path = []
when String then want == path.pop
when Symbol then capture[ want ] = path.pop
when Regexp then want === path.pop
when Hash
key, value = want.to_a.first
case value
when true then
capture[ key ] = path.reverse
path = []
when String, Symbol
got = path.pop
capture[ key ] = got ? got : want.to_s
when Regexp then
got = path.pop
capture[ key ] = got if value === got
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment