Created
September 21, 2016 20:37
-
-
Save anonymous/40ae511acdb0ac7e375452f352a9e386 to your computer and use it in GitHub Desktop.
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
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