Module: Apidiesel::Dsl
- Included in:
- Action
- Defined in:
- lib/apidiesel/dsl.rb
Defined Under Namespace
Classes: ExpectationBuilder, FilterBuilder
Instance Method Summary collapse
-
#expects {|Apidiesel::Dsl::ExpectationBuilder| ... } ⇒ Object
Defines the input parameters expected for this API action.
-
#responds_with(**args) {|Apidiesel::Dsl::FilterBuilder| ... } ⇒ Object
Defines the expected content and format of the response for this API action.
Instance Method Details
#expects {|Apidiesel::Dsl::ExpectationBuilder| ... } ⇒ Object
Defines the input parameters expected for this API action.
See the ExpectationBuilder instance methods
for more information on what to use within expect
.
16 17 18 19 20 21 |
# File 'lib/apidiesel/dsl.rb', line 16 def expects(&block) builder = ExpectationBuilder.new builder.instance_eval(&block) parameter_validations.concat builder.parameter_validations parameters_to_filter.concat builder.parameters_to_filter end |
#responds_with(**args) {|Apidiesel::Dsl::FilterBuilder| ... } ⇒ Object
Defines the expected content and format of the response for this API action.
See the FilterBuilder instance methods
for more information on what to use within responds_with
.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/apidiesel/dsl.rb', line 35 def responds_with(**args, &block) builder = FilterBuilder.new builder.instance_eval(&block) response_filters.concat(builder.response_filters) response_formatters.concat(builder.response_formatters) if args[:unnested_hash] response_formatters << lambda do |_, response| if response.is_a?(Hash) && response.keys.length == 1 response.values.first else response end end end end |