class SoberSwag::Reporting::Output::Dictionary
Output
a dictionary of key-value pairs.
Attributes
value_output[R]
Public Class Methods
new(value_output)
click to toggle source
# File lib/sober_swag/reporting/output/dictionary.rb, line 11 def initialize(value_output) @value_output = value_output end
of(valout)
click to toggle source
# File lib/sober_swag/reporting/output/dictionary.rb, line 7 def self.of(valout) new(valout) end
Public Instance Methods
call(item)
click to toggle source
# File lib/sober_swag/reporting/output/dictionary.rb, line 17 def call(item) item.transform_values { |v| value_output.call(v) } end
serialize_report(item)
click to toggle source
# File lib/sober_swag/reporting/output/dictionary.rb, line 21 def serialize_report(item) return Report::Base.new(['was not a dict']) unless item.is_a?(Hash) bad, good = item.map { |k, v| [k, value_output.serialize_report(v)] }.compact.partition { |(_, v)| v.is_a?(Report::Base) } return Report::Object.new(bad.to_h) if bad.any? good.to_h end
swagger_schema()
click to toggle source
# File lib/sober_swag/reporting/output/dictionary.rb, line 33 def swagger_schema schema, found = value_output.swagger_schema [ { type: :object, additionalProperties: schema }, found ] end