Module: Evostream::Configuration
- Included in:
- Evostream
- Defined in:
- lib/evostream/configuration.rb
Constant Summary collapse
- VALID_CONFIG_KEYS =
[:host, :port, :path_prefix, :timeout].freeze
- OPTIONAL_CONFIG_KEYS =
VALID_CONFIG_KEYS - [:host]
- DEFAULT_PORT =
80- DEFAULT_PATH_PREFIX =
''- DEFAULT_TIMEOUT =
5
Class Method Summary collapse
-
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
config/initializers/evostream.rb (for instance).
- #options ⇒ Object
- #reset ⇒ Object
Class Method Details
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’
16 17 18 |
# File 'lib/evostream/configuration.rb', line 16 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
config/initializers/evostream.rb (for instance)
Evostream.configure do |config|
config.host = 'evostream.example.com'
config.port = 80
config.path_prefix = '/evo'
end
elsewhere
client = Evostream::Client.new
38 39 40 41 |
# File 'lib/evostream/configuration.rb', line 38 def configure yield self true end |
#options ⇒ Object
43 44 45 |
# File 'lib/evostream/configuration.rb', line 43 def Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ] end |
#reset ⇒ Object
20 21 22 23 24 |
# File 'lib/evostream/configuration.rb', line 20 def reset self.port = DEFAULT_PORT self.path_prefix = DEFAULT_PATH_PREFIX self.timeout = DEFAULT_TIMEOUT end |