Class: Trane::ParamDefinition

Inherits:
Data
  • Object
show all
Defined in:
lib/trane/param_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, location:, required: false, enum: nil) ⇒ ParamDefinition

Build a frozen param definition for an operation request schema.

Parameters:

  • name (Symbol, String)

    coerced to Symbol

  • type (Symbol, String)

    coerced to Symbol

  • location (Symbol, String)

    one of :path, :query; coerced to Symbol

  • required (Boolean) (defaults to: false)

    whether the param must be present in the request. Defaults to false. DSL callers override per location: path always passes true; query honours the caller's required: keyword (also defaulting to false).

  • enum (Array, nil) (defaults to: nil)

    frozen on assignment



15
16
17
18
19
20
21
22
23
# File 'lib/trane/param_definition.rb', line 15

def initialize(name:, type:, location:, required: false, enum: nil)
  super(
    name: name.to_sym,
    type: type.to_sym,
    required: required,
    location: location.to_sym,
    enum: enum&.freeze
  )
end

Instance Attribute Details

#enumObject (readonly)

Returns the value of attribute enum

Returns:

  • (Object)

    the current value of enum



4
5
6
# File 'lib/trane/param_definition.rb', line 4

def enum
  @enum
end

#locationObject (readonly)

Returns the value of attribute location

Returns:

  • (Object)

    the current value of location



4
5
6
# File 'lib/trane/param_definition.rb', line 4

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/trane/param_definition.rb', line 4

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required

Returns:

  • (Object)

    the current value of required



4
5
6
# File 'lib/trane/param_definition.rb', line 4

def required
  @required
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/trane/param_definition.rb', line 4

def type
  @type
end