module Eventum::Configurable

Configuration options for {self} with default values

@!attribute [rw] adapter

The adapter to be used by Faraday. Defaults to `:net_http`. Other
options include `:typhoeus`, `:patron`, `:excon`, `:test`

@!attribute [rw] host

The host of the Event Store instance. Defaults to `http://localhost`

@!attribute [rw] port

The port of the Event Store instance. Defaults to `2113`

Constants

ADAPTER

Default Faraday adapter

@return [Symbol]

HOST

Default Event Store host

@return [String]

PORT

Default Event Store port

@return [String]

Public Instance Methods

config_props() click to toggle source

List of configuration properties

@return [Array]

@api public

# File lib/eventum/configurable.rb, line 61
def config_props
  %i(adapter host port)
end
configure() { |self| ... } click to toggle source

Allows to configure {self}

@example

Eventum.configure do |config|
  config.adapter = :typhoeus
  config.host = "http://localhost"
  config.port = 2121
end

@yield [self]

A configurable object

@return [nil]

@api public

# File lib/eventum/configurable.rb, line 52
def configure
  yield self if block_given?
end
reset!() click to toggle source

Resets the configuration properties to default values

@return [nil]

@api public

# File lib/eventum/configurable.rb, line 70
def reset!
  config_props.each do |prop|
    instance_variable_set(:"@#{prop}", defaults[prop])
  end
end

Private Instance Methods

defaults() click to toggle source

Holds default configuration

@return [Hash]

@api private

# File lib/eventum/configurable.rb, line 83
def defaults
  {
    adapter: ADAPTER,
    host:    HOST,
    port:    PORT
  }.freeze
end