Class: Legion::Extensions::Agentic::Social::Mirror::Helpers::MirrorEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent_id:, action_type:, context: {}, emotional_valence: 0.0) ⇒ MirrorEvent

Returns a new instance of MirrorEvent.



14
15
16
17
18
19
20
21
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 14

def initialize(agent_id:, action_type:, context: {}, emotional_valence: 0.0)
  @id               = SecureRandom.uuid
  @agent_id         = agent_id
  @action_type      = normalize_action_type(action_type)
  @context          = context.is_a?(Hash) ? context : {}
  @emotional_valence = emotional_valence.to_f.clamp(-1.0, 1.0)
  @observed_at = Time.now.utc
end

Instance Attribute Details

#action_typeObject (readonly)

Returns the value of attribute action_type.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def action_type
  @action_type
end

#agent_idObject (readonly)

Returns the value of attribute agent_id.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def agent_id
  @agent_id
end

#contextObject (readonly)

Returns the value of attribute context.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def context
  @context
end

#emotional_valenceObject (readonly)

Returns the value of attribute emotional_valence.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def emotional_valence
  @emotional_valence
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def id
  @id
end

#observed_atObject (readonly)

Returns the value of attribute observed_at.



12
13
14
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 12

def observed_at
  @observed_at
end

Instance Method Details

#to_hObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/legion/extensions/agentic/social/mirror/helpers/mirror_event.rb', line 23

def to_h
  {
    id:                @id,
    agent_id:          @agent_id,
    action_type:       @action_type,
    context:           @context,
    emotional_valence: @emotional_valence,
    observed_at:       @observed_at
  }
end