Module: Grape::DSL::Desc
Constant Summary collapse
- ROUTE_ATTRIBUTES =
%i[ body_name consumes default deprecated description detail entity headers hidden http_codes is_array named nickname params produces security summary tags ].freeze
Instance Attribute Summary
Attributes included from Settings
#inheritable_setting, #top_level_setting
Instance Method Summary collapse
-
#desc(description, options = nil) { ... } ⇒ Object
Add a description to the next namespace or function.
-
#desc_container(endpoint_configuration) ⇒ Object
Returns an object which configures itself via an instance-context DSL.
Methods included from Settings
#api_class_setting, #get_or_set, #global_setting, #namespace_end, #namespace_inheritable, #namespace_inheritable_to_nil, #namespace_reverse_stackable, #namespace_reverse_stackable_with_hash, #namespace_setting, #namespace_stackable, #namespace_stackable_with_hash, #namespace_start, #route_end, #route_setting, #unset, #unset_api_class_setting, #unset_global_setting, #unset_namespace_inheritable, #unset_namespace_setting, #unset_namespace_stackable, #unset_route_setting, #within_namespace
Instance Method Details
#desc(description, options = nil) { ... } ⇒ Object
Add a description to the next namespace or function.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/grape/dsl/desc.rb', line 73 def desc(description, = nil, &config_block) opts = if config_block desc_container(endpoint_configuration).then do |config_class| config_class.configure do description(description) end config_class.configure(&config_block) config_class.settings end else &.merge(description: description) || { description: description } end namespace_setting :description, opts route_setting :description, opts end |
#desc_container(endpoint_configuration) ⇒ Object
Returns an object which configures itself via an instance-context DSL.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/grape/dsl/desc.rb', line 93 def desc_container(endpoint_configuration) Module.new do include Grape::Util::StrictHashConfiguration.module(*ROUTE_ATTRIBUTES) config_context.define_singleton_method(:configuration) do endpoint_configuration end def config_context.success(*args) entity(*args) end def config_context.failure(*args) http_codes(*args) end end end |