Skip to content

Instantly share code, notes, and snippets.

@philtr
Created January 18, 2017 20:00
Show Gist options
  • Save philtr/0fa63f05018353188a68a524b1f24142 to your computer and use it in GitHub Desktop.
Save philtr/0fa63f05018353188a68a524b1f24142 to your computer and use it in GitHub Desktop.
OpenStruct-based Configuration Class
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