Class: RequestParamsValidation::Definitions::Request
- Inherits:
-
Object
- Object
- RequestParamsValidation::Definitions::Request
- Defined in:
- lib/request_params_validation/definitions/request.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #optional(param_name, options = {}, &block) ⇒ Object
- #required(param_name, options = {}, &block) ⇒ Object
Constructor Details
#initialize ⇒ Request
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
#params ⇒ Object (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, = {}, &block) = .merge({ required: false }) add_parameter(param_name, , &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, = {}, &block) = .merge({ required: true }) add_parameter(param_name, , &block) end |