Class: Kreator::PluginToolAdapter
- Inherits:
-
Object
- Object
- Kreator::PluginToolAdapter
- Defined in:
- lib/kreator/plugin_tool.rb
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
Instance Method Summary collapse
- #call(args:, context:, signal:) ⇒ Object
- #description ⇒ Object
-
#initialize(plugin:, instance:) ⇒ PluginToolAdapter
constructor
A new instance of PluginToolAdapter.
- #name ⇒ Object
- #schema ⇒ Object
- #to_h ⇒ Object
- #tool_name ⇒ Object
Constructor Details
#initialize(plugin:, instance:) ⇒ PluginToolAdapter
Returns a new instance of PluginToolAdapter.
30 31 32 33 |
# File 'lib/kreator/plugin_tool.rb', line 30 def initialize(plugin:, instance:) @plugin = plugin @instance = instance end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
28 29 30 |
# File 'lib/kreator/plugin_tool.rb', line 28 def instance @instance end |
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
28 29 30 |
# File 'lib/kreator/plugin_tool.rb', line 28 def plugin @plugin end |
Instance Method Details
#call(args:, context:, signal:) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kreator/plugin_tool.rb', line 51 def call(args:, context:, signal:) context.approve_plugin_tool!( plugin: plugin.name, tool: name, description: description, args: args ) result = instance.call(args: args, context: context, signal: signal) annotate_result(result) end |
#description ⇒ Object
43 44 45 |
# File 'lib/kreator/plugin_tool.rb', line 43 def description instance.class.description end |
#name ⇒ Object
35 36 37 |
# File 'lib/kreator/plugin_tool.rb', line 35 def name "#{plugin.name}.#{tool_name}" end |
#schema ⇒ Object
47 48 49 |
# File 'lib/kreator/plugin_tool.rb', line 47 def schema instance.class.schema end |
#to_h ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/kreator/plugin_tool.rb', line 62 def to_h { "plugin" => plugin.name, "name" => name, "tool_name" => tool_name, "description" => description, "schema" => schema } end |
#tool_name ⇒ Object
39 40 41 |
# File 'lib/kreator/plugin_tool.rb', line 39 def tool_name instance.class.tool_name end |