Class: RequestParamsValidation::Definitions::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/request_params_validation/definitions/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRequest

Returns a new instance of Request.



8
9
10
# File 'lib/request_params_validation/definitions/request.rb', line 8

def initialize
  @params = []
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/request_params_validation/definitions/request.rb', line 6

def params
  @params
end

Instance Method Details

#optional(param_name, options = {}, &block) ⇒ Object



17
18
19
20
# File 'lib/request_params_validation/definitions/request.rb', line 17

def optional(param_name, options = {}, &block)
  options = options.merge({ required: false })
  add_parameter(param_name, options, &block)
end

#required(param_name, options = {}, &block) ⇒ Object



12
13
14
15
# File 'lib/request_params_validation/definitions/request.rb', line 12

def required(param_name, options = {}, &block)
  options = options.merge({ required: true })
  add_parameter(param_name, options, &block)
end