Skip to content

Instantly share code, notes, and snippets.

@jphenow
Created October 15, 2013 19:30
Show Gist options
  • Save jphenow/6997322 to your computer and use it in GitHub Desktop.
Save jphenow/6997322 to your computer and use it in GitHub Desktop.
Fancy deep fetching
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