Created
January 18, 2017 20:00
-
-
Save philtr/0fa63f05018353188a68a524b1f24142 to your computer and use it in GitHub Desktop.
OpenStruct-based Configuration Class
This file contains hidden or 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 Configuration < OpenStruct | |
def self.configure(&block) | |
yield config | |
end | |
def self.config | |
@_configuration ||= new | |
end | |
def method_missing(method, *args) | |
if method =~ /\?\Z/ | |
!!self[method[0..-2]] | |
else | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment