Class: Meta::RouteDSL::UniformedParamsBuilder
- Inherits:
-
Object
- Object
- Meta::RouteDSL::UniformedParamsBuilder
- Defined in:
- lib/meta/route_dsl/uniformed_params_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(route_full_path:, route_method:, &block) ⇒ UniformedParamsBuilder
constructor
A new instance of UniformedParamsBuilder.
- #param(name, options = {}, &block) ⇒ Object
- #property(name, options = {}, &block) ⇒ Object
Constructor Details
#initialize(route_full_path:, route_method:, &block) ⇒ UniformedParamsBuilder
Returns a new instance of UniformedParamsBuilder.
6 7 8 9 10 11 12 13 14 |
# File 'lib/meta/route_dsl/uniformed_params_builder.rb', line 6 def initialize(route_full_path:, route_method:, &block) @route_full_path = route_full_path @route_method = route_method @parameters_builder = ParametersBuilder.new(route_full_path: @route_full_path, route_method: @route_method) @parameter_options = {} instance_exec &block if block_given? end |
Instance Method Details
#build ⇒ Object
39 40 41 |
# File 'lib/meta/route_dsl/uniformed_params_builder.rb', line 39 def build [@parameters_builder.build, @request_body_builder&.to_schema] end |
#param(name, options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/meta/route_dsl/uniformed_params_builder.rb', line 16 def param(name, = {}, &block) = ( || {}).dup if path_param_names.include?(name) = Utils::Kwargs::Helpers.fix!(, in: 'path', required: true) elsif @route_method == :get = Utils::Kwargs::Helpers.merge_defaults!(, in: 'query') else = Utils::Kwargs::Helpers.merge_defaults!(, in: 'body') end if [:in] == 'body' .delete(:in) property name, , &block else @parameters_builder.param name, end end |
#property(name, options = {}, &block) ⇒ Object
34 35 36 37 |
# File 'lib/meta/route_dsl/uniformed_params_builder.rb', line 34 def property(name, = {}, &block) @request_body_builder ||= JsonSchema::ObjectSchemaBuilder.new @request_body_builder.property name, , &block end |