Class: RobotLab::HookContext
- Inherits:
-
Object
- Object
- RobotLab::HookContext
- Defined in:
- lib/robot_lab/hook_context.rb
Direct Known Subclasses
CompactionHookContext, LearnHookContext, NetworkRunHookContext, RunHookContext, TaskHookContext, ToolCallHookContext
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
- #ext(name) ⇒ Object
-
#initialize(event:, metadata: nil) ⇒ HookContext
constructor
A new instance of HookContext.
- #local ⇒ Object
- #to_h ⇒ Object
- #with_namespace(namespace) ⇒ Object
Constructor Details
#initialize(event:, metadata: nil) ⇒ HookContext
Returns a new instance of HookContext.
7 8 9 10 |
# File 'lib/robot_lab/hook_context.rb', line 7 def initialize(event:, metadata: nil) @event = event.to_sym @metadata = || ExtensionState.new end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/robot_lab/hook_context.rb', line 5 def event @event end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/robot_lab/hook_context.rb', line 5 def @metadata end |
Instance Method Details
#ext(name) ⇒ Object
12 13 14 |
# File 'lib/robot_lab/hook_context.rb', line 12 def ext(name) .ext(name) end |
#local ⇒ Object
16 17 18 19 20 |
# File 'lib/robot_lab/hook_context.rb', line 16 def local raise ArgumentError, "No hook namespace active" unless @namespace ext(@namespace) end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/robot_lab/hook_context.rb', line 30 def to_h public_snapshot.merge(metadata: .to_h) end |
#with_namespace(namespace) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/robot_lab/hook_context.rb', line 22 def with_namespace(namespace) previous = @namespace @namespace = namespace&.to_sym yield self ensure @namespace = previous end |