Class: Collavre::SystemEvents::ContextBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/services/collavre/system_events/context_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ContextBuilder

Returns a new instance of ContextBuilder.



4
5
6
# File 'app/services/collavre/system_events/context_builder.rb', line 4

def initialize(context)
  @context = context
end

Instance Method Details

#buildObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/collavre/system_events/context_builder.rb', line 8

def build
  # Ensure context is a hash with string keys for Liquid
  ctx = @context.deep_stringify_keys

  # Add helper objects/functions
  if ctx["chat"]
    ctx["chat"]["mentioned_user"] ||= mentioned_user(ctx["chat"])
  end

  # Add sender context for A2A communication
  ctx["sender"] ||= build_sender_context(ctx)

  ctx
end