Class: CircuitBreaker::Executors::DSL::ConfigBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/circuit_breaker/executors/dsl.rb

Instance Method Summary collapse

Constructor Details

#initializeConfigBuilder

Returns a new instance of ConfigBuilder.



21
22
23
24
25
26
27
28
# File 'lib/circuit_breaker/executors/dsl.rb', line 21

def initialize
  @config = {
    parameters: {},
    validations: [],
    before_execute: [],
    after_execute: []
  }
end

Instance Method Details

#after_execute(&block) ⇒ Object



47
48
49
# File 'lib/circuit_breaker/executors/dsl.rb', line 47

def after_execute(&block)
  @config[:after_execute] << block
end

#before_execute(&block) ⇒ Object



43
44
45
# File 'lib/circuit_breaker/executors/dsl.rb', line 43

def before_execute(&block)
  @config[:before_execute] << block
end

#parameter(name, type: nil, required: false, default: nil, description: nil) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/circuit_breaker/executors/dsl.rb', line 30

def parameter(name, type: nil, required: false, default: nil, description: nil)
  @config[:parameters][name] = {
    type: type,
    required: required,
    default: default,
    description: description
  }
end

#to_hObject



51
52
53
# File 'lib/circuit_breaker/executors/dsl.rb', line 51

def to_h
  @config
end

#validate(&block) ⇒ Object



39
40
41
# File 'lib/circuit_breaker/executors/dsl.rb', line 39

def validate(&block)
  @config[:validations] << block
end