Class: JSON::SchemaDsl::Renderers::Multiplexer

Inherits:
Base
  • Object
show all
Defined in:
lib/json/schema_dsl/renderers/multiplexer.rb

Overview

Renderer that translates multiplexer properties (any_of, one_of or all_of) so that a new wrapping structure is returned that holds the original in one of these properties.

Examples:

Nullable object

obj = object :james, any_of: [null]
Multiplexer.new(nil).visit(obj)
  #=> { type: 'entity', any_of: [{type: 'null'}, {type: 'object', ...}] }

Constant Summary collapse

KEYS =
%i[any_of one_of all_of].freeze

Instance Attribute Summary

Attributes inherited from Base

#scope

Instance Method Summary collapse

Methods inherited from Base

#initialize, #traverse

Constructor Details

This class inherits a constructor from JSON::SchemaDsl::Renderers::Base

Instance Method Details

#visit(entity) ⇒ Object

Boxes the entity into a new one with the multiplexer attribute set to the entity, if required.



20
21
22
# File 'lib/json/schema_dsl/renderers/multiplexer.rb', line 20

def visit(entity)
  traverse(box(entity))
end