Class: Trusted::Config::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/trusted/config/builder.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  binding_type: :tcp,
  listen_on: 'localhost:3000',
  thread_pool_size: 1,
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



16
17
18
# File 'lib/trusted/config/builder.rb', line 16

def initialize
  @config = {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/trusted/config/builder.rb', line 4

def config
  @config
end

Class Method Details

.dsl(&block) ⇒ Object



12
13
14
# File 'lib/trusted/config/builder.rb', line 12

def self.dsl(&block)
  Docile.dsl_eval(new, &block).build
end

Instance Method Details

#binding_type(type) ⇒ Object



20
21
22
# File 'lib/trusted/config/builder.rb', line 20

def binding_type(type)
  config[:binding_type] = type
end

#buildObject



32
33
34
35
36
# File 'lib/trusted/config/builder.rb', line 32

def build
  configuration = DEFAULT_CONFIG.merge(config)

  Config.new(configuration)
end

#listen_on(address) ⇒ Object



24
25
26
# File 'lib/trusted/config/builder.rb', line 24

def listen_on(address)
  config[:listen_on] = address
end

#thread_pool_size(size) ⇒ Object



28
29
30
# File 'lib/trusted/config/builder.rb', line 28

def thread_pool_size(size)
  config[:thread_pool_size] = size
end