Class: Rack::App::Middlewares::Params::Definition
- Inherits:
-
Object
- Object
- Rack::App::Middlewares::Params::Definition
- Defined in:
- lib/rack/app/middlewares/params/definition.rb
Instance Method Summary collapse
-
#initialize(&descriptor) ⇒ Definition
constructor
A new instance of Definition.
- #optional(params_key, options) ⇒ Object
- #required(params_key, options) ⇒ Object
- #to_descriptor ⇒ Object
Constructor Details
#initialize(&descriptor) ⇒ Definition
Returns a new instance of Definition.
4 5 6 7 8 |
# File 'lib/rack/app/middlewares/params/definition.rb', line 4 def initialize(&descriptor) @required = {} @optional = {} instance_exec(&descriptor) end |
Instance Method Details
#optional(params_key, options) ⇒ Object
14 15 16 |
# File 'lib/rack/app/middlewares/params/definition.rb', line 14 def optional(params_key, ) @optional[params_key.to_s] = self.class::Options.new().formatted end |
#required(params_key, options) ⇒ Object
10 11 12 |
# File 'lib/rack/app/middlewares/params/definition.rb', line 10 def required(params_key, ) @required[params_key.to_s] = self.class::Options.new().formatted end |
#to_descriptor ⇒ Object
18 19 20 |
# File 'lib/rack/app/middlewares/params/definition.rb', line 18 def to_descriptor { :required => @required, :optional => @optional } end |