Class: LogStruct::ConfigStruct::PathFilterMatcher

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

Overview

A filter that needs more than the key: Rails' entries with a dot (card.number) match a key by its path, and Rails gives filter blocks with three arguments the parameters around the key. The path starts at the line's top-level field (["params", "card", "number"]); root is that field's value, or the whole line for a top-level key, with indifferent access as Rails gives it. Building it copies every value inside it, so a matcher that doesn't read it sets uses_root to false and gets nil.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callable:, label:, uses_root: true) ⇒ void

Parameters:

  • callable (T.proc.params(path: T::Array[String], value: T.untyped, root: T.untyped).returns(T::Boolean))
  • label (String)
  • uses_root (Boolean) (defaults to: true)


# File ''

const :callable, T.proc.params(path: T::Array[String], value: T.untyped, root: T.untyped).returns(T::Boolean)
const :label, String
const :uses_root, T::Boolean, default: true

Instance Attribute Details

#callable ⇒ T.proc.params(path: T::Array[String], value: T.untyped, root: T.untyped).returns(T::Boolean) (readonly)

Returns the value of prop callable.

Returns:

  • (T.proc.params(path: T::Array[String], value: T.untyped, root: T.untyped).returns(T::Boolean))


# File ''

const :callable, T.proc.params(path: T::Array[String], value: T.untyped, root: T.untyped).returns(T::Boolean)

#label ⇒ String (readonly)

Returns the value of prop label.

Returns:

  • (String)


# File ''

const :label, String

#uses_root ⇒ Boolean (readonly)

Returns the value of prop uses_root.

Returns:

  • (Boolean)


# File ''

const :uses_root, T::Boolean, default: true

Instance Method Details

#matches?(path, value, root) ⇒ Boolean

Parameters:

  • path (Array<String>)
  • value (T.untyped)
  • root (T.untyped)

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/log_struct/config_struct/filters.rb', line 51

def matches?(path, value, root)
  root = nil unless uses_root
  callable.call(path, value, root.is_a?(LazyRoot) ? root.value : root)
end