Class: TraceViz::Context::ConfigContext

Inherits:
BaseContext show all
Defined in:
lib/trace_viz/context/config_context.rb

Instance Attribute Summary collapse

Attributes inherited from BaseContext

#options

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ ConfigContext



10
11
12
13
14
# File 'lib/trace_viz/context/config_context.rb', line 10

def initialize(**options)
  super

  @configuration = apply_options(options)
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



8
9
10
# File 'lib/trace_viz/context/config_context.rb', line 8

def configuration
  @configuration
end

Instance Method Details

#apply_options(options) ⇒ Object

Apply the overrides from options



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/trace_viz/context/config_context.rb', line 21

def apply_options(options)
  options.each do |key, value|
    if temp_configuration.respond_to?("#{key}=")
      temp_configuration.send("#{key}=", value)
    else
      TraceViz.logger.warn("Unknown configuration option '#{key}'")
    end
  end

  temp_configuration
end

#temp_configurationObject



16
17
18
# File 'lib/trace_viz/context/config_context.rb', line 16

def temp_configuration
  @temp_configuration ||= TraceViz.configuration.dup
end