Class: Trailblazer::Developer::Trace::Snapshot::Value
- Inherits:
-
Object
- Object
- Trailblazer::Developer::Trace::Snapshot::Value
- Defined in:
- lib/trailblazer/developer/trace/snapshot/value.rb
Overview
Value serializes the variable value using with custom logic, e.g. valuevalue.inspect. A series of matchers decide which snapshooter is used.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(name, value, **options) ⇒ Object
DISCUSS: this could be a compiled pattern matching ‘case/in` block here.
-
#initialize(matchers) ⇒ Value
constructor
A new instance of Value.
Constructor Details
#initialize(matchers) ⇒ Value
Returns a new instance of Value.
7 8 9 |
# File 'lib/trailblazer/developer/trace/snapshot/value.rb', line 7 def initialize(matchers) @matchers = matchers end |
Class Method Details
.build ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trailblazer/developer/trace/snapshot/value.rb', line 26 def self.build new( [ [ ->(*) { true }, # matches everything method(:default_variable_inspect) ] ] ) end |
.default_variable_inspect(name, value, ctx:) ⇒ Object
22 23 24 |
# File 'lib/trailblazer/developer/trace/snapshot/value.rb', line 22 def self.default_variable_inspect(name, value, ctx:) value.inspect end |
Instance Method Details
#call(name, value, **options) ⇒ Object
DISCUSS: this could be a compiled pattern matching ‘case/in` block here.
12 13 14 15 16 17 18 19 20 |
# File 'lib/trailblazer/developer/trace/snapshot/value.rb', line 12 def call(name, value, **) @matchers.each do |matcher, inspect_method| if matcher.(name, value, **) return inspect_method.(name, value, **) end end raise "no matcher found for #{name.inspect}" # TODO: this should never happen. end |