Created
October 15, 2013 19:30
-
-
Save jphenow/6997322 to your computer and use it in GitHub Desktop.
Fancy deep fetching
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
module ApplicationHelper | |
def fetch_param(*key_names) | |
result = key_names.reduce(params) { |fetchable, param| | |
fetchable.fetch(param, {}) | |
} | |
result.is_a?(Hash) && result.empty? ? nil : result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment