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
7 8 9 10 11 12 13 14 15 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 7 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
21 22 23 24 25 26 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 21 def default_values { host: 'host_with_port', base_path: 'script_name' } end |
.evaluate(key, options, request) ⇒ Object
17 18 19 |
# File 'lib/grape-swagger/doc_methods/optional_object.rb', line 17 def evaluate(key, , request) [key].arity.zero? ? [key].call : [key].call(request) end |