Sha256: a1183426455215a2426339455a8a747ccd91b2cf5e1552dbd839e515c6d9bed5
Contents?: true
Size: 1.03 KB
Versions: 7
Compression:
Stored size: 1.03 KB
Contents
module SoberSwag module Reporting module Output ## # Output a dictionary of key-value pairs. class Dictionary < Base def self.of(valout) new(valout) end def initialize(value_output) @value_output = value_output end attr_reader :value_output def call(item) item.transform_values { |v| value_output.call(v) } end 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 def swagger_schema schema, found = value_output.swagger_schema [ { type: :object, additionalProperties: schema }, found ] end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems