Class: LogStruct::ConfigStruct::LazyRoot

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/log_struct/config_struct/filters.rb

Overview

The root a PathFilterMatcher gets, built the first time a matcher reads it

Constant Summary collapse

UNAVAILABLE =
Object.new.freeze

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ void

Parameters:

  • value (T.untyped)


68
69
70
71
72
# File 'lib/log_struct/config_struct/filters.rb', line 68

def initialize(value)
  @source = value
  @built = T.let(false, T::Boolean)
  @value = T.let(nil, T.untyped)
end

Instance Method Details

#value ⇒ T.untyped

The value with indifferent access, as Rails gives filter blocks the request's parameters

Returns:

  • (T.untyped)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/log_struct/config_struct/filters.rb', line 76

def value
  return @value if @built

  state = BoundedInput::State.new
  bounded = BoundedInput.copy(@source, state: state)
  @value = if state.truncated
    UNAVAILABLE
  elsif bounded.is_a?(Hash)
    ActiveSupport::HashWithIndifferentAccess.new(bounded)
  else
    bounded
  end
  @built = true
  @value
rescue SystemStackError, StandardError
  @built = true
  @value = UNAVAILABLE
end