Skip to content

Instantly share code, notes, and snippets.

@andrewtimberlake
Created March 26, 2009 11:57
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 andrewtimberlake/86042 to your computer and use it in GitHub Desktop.
Save andrewtimberlake/86042 to your computer and use it in GitHub Desktop.
class AppServerConfiguration
attr_accessor :port, :admin_password
end
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def app_server(&block)
if block_given?
@app_server_config = AppServerConfiguration.new
block.call(@app_server_config)
end
@app_server_config
end
end
def configure(&block)
config = Configuration.new
block.call(config)
config
end
configuration = configure do |config|
config.tail_logs = true
config.max_connections = 55
config.admin_password = 'secret'
config.app_server do |app_server_config|
app_server_config.port = 8808
app_server_config.admin_password = config.admin_password
end
end
p configuration.class
p configuration.tail_logs
p configuration.app_server.admin_password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment