Class: Toolchest::ToolBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/toolchest/tool_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeToolBuilder

Returns a new instance of ToolBuilder.



5
# File 'lib/toolchest/tool_builder.rb', line 5

def initialize = @params = []

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/toolchest/tool_builder.rb', line 3

def params
  @params
end

Instance Method Details

#param(name, type, description = "", **options, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/toolchest/tool_builder.rb', line 7

def param(name, type, description = "", **options, &block)
  @params << ParamDefinition.new(
    name: name,
    type: type,
    description: description,
    optional: options.fetch(:optional, false),
    enum: options[:enum],
    default: options.fetch(:default, :__unset__),
    &block
  )
end