Skip to content

Instantly share code, notes, and snippets.

@drewdeponte
Created January 9, 2012 03:26
Show Gist options
  • Save drewdeponte/1580865 to your computer and use it in GitHub Desktop.
Save drewdeponte/1580865 to your computer and use it in GitHub Desktop.
rack-mount route generate
def generate(method, params = {}, recall = {}, options = {})
puts "DREW: method: #{method}"
puts "DREW: params: #{params.inspect}"
puts "DREW: recall: #{recall.inspect}"
puts "DREW: options: #{options.inspect}"
if method.nil?
result = Hash[@conditions.map { |m, condition|
[m, condition.generate(params, recall, options)] if condition.respond_to?(:generate)
}]
return nil if result.values.compact.empty?
else
if condition = @conditions[method]
if condition.respond_to?(:generate)
result = condition.generate(params, recall, options)
end
end
end
if result
@defaults.each do |key, value|
params.delete(key) if params[key] == value
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment