Skip to content

Instantly share code, notes, and snippets.

@garethrees
Last active December 11, 2015 02:28
Show Gist options
  • Save garethrees/4530610 to your computer and use it in GitHub Desktop.
Save garethrees/4530610 to your computer and use it in GitHub Desktop.
def hash_options(args, defaults)
args.assert_valid_keys(*defaults.keys)
options = defaults.merge(args)
end
def my_method(args = {})
options = hash_options(args, :some => 'value')
# Use
if options[:some]
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment