Created
January 9, 2012 03:26
-
-
Save drewdeponte/1580865 to your computer and use it in GitHub Desktop.
rack-mount route generate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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