Class: Verquest::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/verquest/configuration.rb

Overview

Configuration for the Verquest gem

This class manages configuration settings for the Verquest gem, including validation behavior, JSON Schema version, and version resolution strategy. It’s used to customize the behavior of versioned API requests.

Examples:

Basic configuration

Verquest.configure do |config|
  config.validate_params = true
  config.current_version = -> { Current.api_version }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initialize a new Configuration with default values



43
44
45
46
47
48
49
# File 'lib/verquest/configuration.rb', line 43

def initialize
  @validate_params = true
  @json_schema_version = :draft6
  @validation_error_handling = :raise # or :result
  @remove_extra_root_keys = true
  @version_resolver = VersionResolver
end

Instance Attribute Details

#current_version#call

A callable object that returns the current API version to use when not explicitly specified

Returns:

  • (#call)

    An object responding to call that determines the current version



38
39
40
# File 'lib/verquest/configuration.rb', line 38

def current_version
  @current_version
end

#json_schema_versionSymbol

The JSON Schema draft version to use for validation and schema generation (see the json-schema gem)

Returns:

  • (Symbol)

    The JSON Schema version (e.g., :draft4, :draft5)



29
# File 'lib/verquest/configuration.rb', line 29

attr_accessor :validate_params, :json_schema_version, :validation_error_handling, :remove_extra_root_keys

#remove_extra_root_keysBoolean

Controls if extra root keys not defined in the schema should be removed from the parameters

Returns:

  • (Boolean)

    true if extra keys should be removed, false otherwise



29
# File 'lib/verquest/configuration.rb', line 29

attr_accessor :validate_params, :json_schema_version, :validation_error_handling, :remove_extra_root_keys

#validate_paramsBoolean

Controls whether parameters are automatically validated against the schema

Returns:

  • (Boolean)

    true if validation is enabled, false otherwise



29
30
31
# File 'lib/verquest/configuration.rb', line 29

def validate_params
  @validate_params
end

#validation_error_handlingSymbol

Controls how errors during parameter processing are handled

Returns:

  • (Symbol)

    :raise to raise errors (default) or :result to return errors in the Result object



29
# File 'lib/verquest/configuration.rb', line 29

attr_accessor :validate_params, :json_schema_version, :validation_error_handling, :remove_extra_root_keys

#version_resolverObject

Returns the value of attribute version_resolver.



38
# File 'lib/verquest/configuration.rb', line 38

attr_reader :current_version, :version_resolver