class SoberSwag::Reporting::Output::List
Serialize a list of some other output type. Passes views down.
Attributes
element_output[R]
Public Class Methods
new(element_output)
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 8 def initialize(element_output) @element_output = element_output end
Public Instance Methods
call(input)
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 22 def call(input) input.map { |i| element_output.call(i) } end
serialize_report(input)
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 37 def serialize_report(input) return Report::Value.new(['could not be made an array']) unless input.respond_to?(:map) errs = {} mapped = input.map.with_index do |item, idx| element_output.serialize_report(item).tap { |e| errs[idx] = e if e.is_a?(Report::Base) } end if errs.any? Report::List.new(errs) else mapped end end
swagger_schema()
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 26 def swagger_schema schema, found = element_output.swagger_schema [ { type: 'array', items: schema }, found ] end
view(view)
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 14 def view(view) List.new(element_output.view(view)) end
views()
click to toggle source
# File lib/sober_swag/reporting/output/list.rb, line 18 def views element_output.views end