Class: GrapeSwagger::DocMethods::OptionalObject
- Inherits:
-
Object
- Object
- GrapeSwagger::DocMethods::OptionalObject
- Defined in:
- lib/grape-swagger/doc_methods/optional_object.rb
Class Method Summary collapse
- .build(key, options, request = nil) ⇒ Object
- .default_values ⇒ Object
- .evaluate(key, options, request) ⇒ Object
Class Method Details
.build(key, options, request = nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 5 def build(key, , request = nil) if [key] return evaluate(key, , request) if [key].is_a?(Proc) [key] else request.send(default_values[key]) end end |
.default_values ⇒ Object
18 19 20 21 22 23 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 18 def default_values { host: 'host_with_port', base_path: 'script_name' } end |
.evaluate(key, options, request) ⇒ Object
14 15 16 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 14 def evaluate(key, , request) [key].arity.zero? ? [key].call : [key].call(request) end |