Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2016 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/40ae511acdb0ac7e375452f352a9e386 to your computer and use it in GitHub Desktop.
Save anonymous/40ae511acdb0ac7e375452f352a9e386 to your computer and use it in GitHub Desktop.
class Foo
def initialize(opts)
@config ||= configure(opts)
end
private
configure(opts)
if opts.nil? || opts.empty?
raise ArgumentError, 'Options argument cannot be nil or empty'
end
if opts.class == Hash
config = {}
opts.each do |k, v|
config[k.to_sym] = v if valid_key?(k)
end
end
config
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment