Class: Committee::SchemaValidator::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/committee/schema_validator/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, schema, schema_type) ⇒ Option

Returns a new instance of Option.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/committee/schema_validator/option.rb', line 29

def initialize(options, schema, schema_type)
  # Non-boolean options
  @headers_key         = options[:headers_key]    || "committee.headers"
  @params_key          = options[:params_key]     || "committee.params"
  @query_hash_key      = if options[:query_hash_key].nil?
    Committee.warn_deprecated('Committee: please set query_hash_key = rack.request.query_hash because we\'ll change default value in next major version.') 
    'rack.request.query_hash'
  else
    options.fetch(:query_hash_key)
  end
  @path_hash_key      = options[:path_hash_key] || "committee.path_hash"
  @request_body_hash_key = options[:request_body_hash_key] || "committee.request_body_hash"

  @prefix              = options[:prefix]

  # Boolean options and have a common value by default
  @allow_form_params   = options.fetch(:allow_form_params, true)
  @allow_query_params  = options.fetch(:allow_query_params, true)
  @check_content_type  = options.fetch(:check_content_type, true)
  @check_header        = options.fetch(:check_header, true)
  @coerce_recursive    = options.fetch(:coerce_recursive, true)
  @optimistic_json     = options.fetch(:optimistic_json, false)
  @parse_response_by_content_type = if options[:parse_response_by_content_type].nil?
    Committee.warn_deprecated('Committee: please set parse_response_by_content_type = false because we\'ll change default value in next major version.') 
    false
  else
    options.fetch(:parse_response_by_content_type)
  end

  # Boolean options and have a different value by default
  @allow_get_body      = options.fetch(:allow_get_body, schema.driver.default_allow_get_body)
  @coerce_date_times   = options.fetch(:coerce_date_times, schema.driver.default_coerce_date_times)
  @coerce_form_params  = options.fetch(:coerce_form_params, schema.driver.default_coerce_form_params)
  @coerce_path_params  = options.fetch(:coerce_path_params, schema.driver.default_path_params)
  @coerce_query_params = options.fetch(:coerce_query_params, schema.driver.default_query_params)
  @validate_success_only = options.fetch(:validate_success_only, schema.driver.default_validate_success_only)
end

Instance Attribute Details

#allow_form_paramsObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def allow_form_params
  @allow_form_params
end

#allow_get_bodyObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def allow_get_body
  @allow_get_body
end

#allow_query_paramsObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def allow_query_params
  @allow_query_params
end

#check_content_typeObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def check_content_type
  @check_content_type
end

#check_headerObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def check_header
  @check_header
end

#coerce_date_timesObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def coerce_date_times
  @coerce_date_times
end

#coerce_form_paramsObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def coerce_form_params
  @coerce_form_params
end

#coerce_path_paramsObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def coerce_path_params
  @coerce_path_params
end

#coerce_query_paramsObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def coerce_query_params
  @coerce_query_params
end

#coerce_recursiveObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def coerce_recursive
  @coerce_recursive
end

#headers_keyObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def headers_key
  @headers_key
end

#optimistic_jsonObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def optimistic_json
  @optimistic_json
end

#params_keyObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def params_key
  @params_key
end

#parse_response_by_content_typeObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def parse_response_by_content_type
  @parse_response_by_content_type
end

#path_hash_keyObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def path_hash_key
  @path_hash_key
end

#prefixObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def prefix
  @prefix
end

#query_hash_keyObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def query_hash_key
  @query_hash_key
end

#request_body_hash_keyObject (readonly)

Non-boolean options:



22
23
24
# File 'lib/committee/schema_validator/option.rb', line 22

def request_body_hash_key
  @request_body_hash_key
end

#validate_success_onlyObject (readonly)

Boolean Options



7
8
9
# File 'lib/committee/schema_validator/option.rb', line 7

def validate_success_only
  @validate_success_only
end