Sha256: 83cb533f4527e01904c97da7b8931a066038ac8a7cb2a94a5ee530d8cbf6ba4b
Contents?: true
Size: 1.09 KB
Versions: 12
Compression:
Stored size: 1.09 KB
Contents
module OpenApi # https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#discriminatorObject class Discriminator prepend EquatableAsContent attr_accessor :property_name, :mapping def initialize(property_name: nil, mapping: {}, **other_fields_hash) self.property_name = property_name self.mapping = mapping.with_indifferent_access self.other_fields_hash = other_fields_hash other_fields_hash.keys.each do |field_name| define_singleton_method(field_name) do other_fields_hash[field_name] end define_singleton_method("#{field_name}=") do |value| other_fields_hash[field_name] = value end end end def self.load(hash) return unless hash fixed_field_names = %w(propertyName mapping) other_fields_hash = hash.reject { |key| key.to_s.in?(fixed_field_names) } new( property_name: hash["propertyName"].to_s, mapping: hash["mapping"], **other_fields_hash.symbolize_keys, ) end private attr_accessor :other_fields_hash end end
Version data entries
12 entries across 12 versions & 1 rubygems