Configuration
This commit is contained in:
parent
6e9208cbce
commit
00b68320a7
29
lib/burlesque/config.rb
Normal file
29
lib/burlesque/config.rb
Normal file
@ -0,0 +1,29 @@
|
||||
module Burlesque
|
||||
class Config
|
||||
attr_accessor :host, :port, :timeout
|
||||
|
||||
def initialize
|
||||
@host = "127.0.0.1"
|
||||
@port = 4401
|
||||
@timeout = 30
|
||||
end
|
||||
end
|
||||
|
||||
module Configurable
|
||||
def configure
|
||||
@config ||= Burlesque::Config.new
|
||||
|
||||
yield @config if block_given?
|
||||
end
|
||||
|
||||
def config
|
||||
unless instance_variable_defined?(:@config)
|
||||
raise ConfigurationError.new("Configuration missing")
|
||||
end
|
||||
|
||||
@config
|
||||
end
|
||||
end
|
||||
|
||||
extend Configurable
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user