Class: WhyChain::DispatchTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/why_chain/dispatch_trace.rb

Overview

Immutable value object for traced dispatch data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lookup_chain:, owner:, next_super_owner:, source_location: nil, steps: []) ⇒ DispatchTrace

Returns a new instance of DispatchTrace.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/why_chain/dispatch_trace.rb', line 8

def initialize(
  lookup_chain:,
  owner:,
  next_super_owner:,
  source_location: nil,
  steps: []
)
  @lookup_chain = lookup_chain
  @owner = owner
  @next_super_owner = next_super_owner
  @source_location = source_location
  @steps = steps.map { |step| coerce_step(step) }
end

Instance Attribute Details

#lookup_chainObject (readonly)

Returns the value of attribute lookup_chain.



6
7
8
# File 'lib/why_chain/dispatch_trace.rb', line 6

def lookup_chain
  @lookup_chain
end

#next_super_ownerObject (readonly)

Returns the value of attribute next_super_owner.



6
7
8
# File 'lib/why_chain/dispatch_trace.rb', line 6

def next_super_owner
  @next_super_owner
end

#ownerObject (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/why_chain/dispatch_trace.rb', line 6

def owner
  @owner
end

#source_locationObject (readonly)

Returns the value of attribute source_location.



6
7
8
# File 'lib/why_chain/dispatch_trace.rb', line 6

def source_location
  @source_location
end

#stepsObject (readonly)

Returns the value of attribute steps.



6
7
8
# File 'lib/why_chain/dispatch_trace.rb', line 6

def steps
  @steps
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
29
30
# File 'lib/why_chain/dispatch_trace.rb', line 22

def to_h
  {
    lookup_chain: lookup_chain,
    owner: owner,
    next_super_owner: next_super_owner,
    source_location: source_location,
    steps: steps.map(&:to_h)
  }
end