Class: Soka::AgentTool::ParamsDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/soka/agent_tool.rb

Overview

Handles parameter definitions for tools

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParamsDefinition

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_paramsObject (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_paramsObject (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

#validationsObject (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, **options)
  param_config = {
    type: type,
    desc: desc
  }
  param_config[:default] = options[:default] if options.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, **options)
  param_config = {
    type: type,
    desc: desc
  }
  param_config[:default] = options[:default] if options.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