Class: Committee::Test::ExceptParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/committee/test/except_parameter.rb

Overview

Handles temporary parameter exclusion during schema validation. Allows testing error responses without validation failures for intentionally missing parameters.

Defined Under Namespace

Modules: StringDummyLookup Classes: BaseHashParameterHandler, BodyHandler, HeaderHandler, QueryHandler

Constant Summary collapse

FORMAT_DUMMIES =
{ 'date-time': '2000-01-01T00:00:00Z', date: '2000-01-01', email: '[email protected]', uuid: '00000000-0000-0000-0000-000000000000' }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(request, committee_options) ⇒ ExceptParameter

Returns a new instance of ExceptParameter.

Parameters:

  • request (Rack::Request)

    The request object

  • committee_options (Hash)

    Committee options hash



12
13
14
15
16
# File 'lib/committee/test/except_parameter.rb', line 12

def initialize(request, committee_options)
  @request = request
  @committee_options = committee_options
  @handlers = {}
end

Instance Method Details

#apply(except) ⇒ void

This method returns an undefined value.

Apply dummy values to excepted parameters

Parameters:

  • except (Hash)

    Hash of parameter types to parameter names (e.g., { headers: [‘authorization’], query: [‘page’] })



22
23
24
25
26
27
# File 'lib/committee/test/except_parameter.rb', line 22

def apply(except)
  except.each do |param_type, param_names|
    handler = (@handlers[param_type] ||= handler_for(param_type))
    handler&.apply(param_names)
  end
end

#restorevoid

This method returns an undefined value.

Restore original parameter values



31
32
33
# File 'lib/committee/test/except_parameter.rb', line 31

def restore
  @handlers.each_value(&:restore)
end