Class: Braintrust::Task::Block
- Inherits:
-
Object
- Object
- Braintrust::Task::Block
- Includes:
- Braintrust::Task
- Defined in:
- lib/braintrust/task.rb
Overview
Block-based task. Stores a Proc and delegates #call to it. Includes Task so it satisfies Task === checks (e.g. in Context::Factory). Exposes #call_parameters so KeywordFilter can introspect the block’s declared kwargs rather than Block#call’s **kwargs signature.
Constant Summary
Constants included from Braintrust::Task
Instance Attribute Summary collapse
- #name ⇒ String readonly
Instance Method Summary collapse
-
#call(**kwargs) ⇒ Object
Result of the block.
-
#call_parameters ⇒ Array<Array>
Exposes the block’s parameter list so KeywordFilter can filter kwargs to match the block’s declared keywords.
-
#initialize(name: DEFAULT_NAME, &block) ⇒ Block
constructor
A new instance of Block.
Methods included from Braintrust::Task
Constructor Details
#initialize(name: DEFAULT_NAME, &block) ⇒ Block
Returns a new instance of Block.
71 72 73 74 |
# File 'lib/braintrust/task.rb', line 71 def initialize(name: DEFAULT_NAME, &block) @name = name @block = wrap_block(block) end |
Instance Attribute Details
#name ⇒ String (readonly)
67 68 69 |
# File 'lib/braintrust/task.rb', line 67 def name @name end |
Instance Method Details
#call(**kwargs) ⇒ Object
Returns result of the block.
78 79 80 |
# File 'lib/braintrust/task.rb', line 78 def call(**kwargs) @block.call(**kwargs) end |
#call_parameters ⇒ Array<Array>
Exposes the block’s parameter list so KeywordFilter can filter kwargs to match the block’s declared keywords.
85 86 87 |
# File 'lib/braintrust/task.rb', line 85 def call_parameters @block.parameters end |