Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Forked from garethrees/hash_options.rb
Created January 14, 2013 15:07
Show Gist options
  • Save ashmoran/4530650 to your computer and use it in GitHub Desktop.
Save ashmoran/4530650 to your computer and use it in GitHub Desktop.
def hash_options(args, defaults)
args.assert_valid_keys(*defaults.keys)
defaults.merge(args).values
end
def my_method(args = {})
some, other, blah =
*hash_options(args, :some => 'value', other: 'value 2', blah: 'value 3')
# Use
if some
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment