Class: TraceViz::Builders::Diagram::MessageBuilder

Inherits:
BaseBuilder
  • Object
show all
Defined in:
lib/trace_viz/builders/diagram/message_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(formatter, participants) ⇒ MessageBuilder

Returns a new instance of MessageBuilder.



11
12
13
14
15
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 11

def initialize(formatter, participants)
  super()
  @formatter = formatter
  @participants_manager = Managers::Diagram::ParticipantsManager.new(participants)
end

Instance Method Details

#build_activate_message(trace) ⇒ Object



47
48
49
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 47

def build_activate_message(trace)
  build(:activate, to: participant_for(trace))
end

#build_call_message(from_trace, to_trace) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 17

def build_call_message(from_trace, to_trace)
  return if same_class?(from_trace, to_trace)

  build(
    :call,
    from: participant_for(from_trace),
    to: participant_for(to_trace),
    content: formatter.format_call,
  )
end

#build_deactivate_message(trace) ⇒ Object



51
52
53
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 51

def build_deactivate_message(trace)
  build(:deactivate, to: participant_for(trace))
end

#build_internal_message(trace) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 55

def build_internal_message(trace)
  build(
    :call,
    from: participant_for(trace),
    to: participant_for(trace),
    content: formatter.format_internal_message(trace),
  )
end

#build_loop_end_messageObject



43
44
45
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 43

def build_loop_end_message
  build(:loop_end)
end

#build_loop_start_message(trace) ⇒ Object



39
40
41
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 39

def build_loop_start_message(trace)
  build(:loop_start, content: "#{trace.count} calls")
end

#build_note(trace) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 64

def build_note(trace)
  build(
    :note,
    from: participant_for(trace),
    to: participant_for(trace),
    content: formatter.format_result(trace),
  )
end

#build_return_message(from_trace, to_trace) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/trace_viz/builders/diagram/message_builder.rb', line 28

def build_return_message(from_trace, to_trace)
  return if same_class?(from_trace, to_trace)

  build(
    :return,
    from: participant_for(from_trace),
    to: participant_for(to_trace),
    content: formatter.format_return,
  )
end