Class: Soka::AgentTool::ParamsDefinition
- Inherits:
-
Object
- Object
- Soka::AgentTool::ParamsDefinition
- Defined in:
- lib/soka/agent_tool.rb
Overview
Handles parameter definitions for tools
Instance Attribute Summary collapse
-
#optional_params ⇒ Object
readonly
Returns the value of attribute optional_params.
-
#required_params ⇒ Object
readonly
Returns the value of attribute required_params.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
Instance Method Summary collapse
-
#initialize ⇒ ParamsDefinition
constructor
A new instance of ParamsDefinition.
- #optional(name, type, desc: nil, **options) ⇒ Object
- #requires(name, type, desc: nil, **options) ⇒ Object
- #validates(name, **rules) ⇒ Object
Constructor Details
#initialize ⇒ ParamsDefinition
Returns a new instance of ParamsDefinition.
21 22 23 24 25 |
# File 'lib/soka/agent_tool.rb', line 21 def initialize @required_params = {} @optional_params = {} @validations = {} end |
Instance Attribute Details
#optional_params ⇒ Object (readonly)
Returns the value of attribute optional_params.
19 20 21 |
# File 'lib/soka/agent_tool.rb', line 19 def optional_params @optional_params end |
#required_params ⇒ Object (readonly)
Returns the value of attribute required_params.
19 20 21 |
# File 'lib/soka/agent_tool.rb', line 19 def required_params @required_params end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
19 20 21 |
# File 'lib/soka/agent_tool.rb', line 19 def validations @validations end |
Instance Method Details
#optional(name, type, desc: nil, **options) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/soka/agent_tool.rb', line 36 def optional(name, type, desc: nil, **) param_config = { type: type, desc: desc } param_config[:default] = [:default] if .key?(:default) @optional_params[name] = param_config end |
#requires(name, type, desc: nil, **options) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/soka/agent_tool.rb', line 27 def requires(name, type, desc: nil, **) param_config = { type: type, desc: desc } param_config[:default] = [:default] if .key?(:default) @required_params[name] = param_config end |
#validates(name, **rules) ⇒ Object
45 46 47 |
# File 'lib/soka/agent_tool.rb', line 45 def validates(name, **rules) @validations[name] = rules end |