Class: JsonModel::Types::AnyOf

Inherits:
Dry::Types::Constructor
  • Object
show all
Defined in:
lib/json_model/types/any_of.rb

Defined Under Namespace

Classes: Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mappingObject (readonly)

Returns the value of attribute mapping.



16
17
18
# File 'lib/json_model/types/any_of.rb', line 16

def mapping
  @mapping
end

#tag_keyObject (readonly)

Returns the value of attribute tag_key.



16
17
18
# File 'lib/json_model/types/any_of.rb', line 16

def tag_key
  @tag_key
end

Instance Method Details

#to_astArray

Returns:

  • (Array)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/json_model/types/any_of.rb', line 19

def to_ast
  [
    :any_of,
    {
      tag_key: options[:tag_key],
      mapping: options[:mapping].transform_values do |type|
        type.respond_to?(:to_ast) ? type.to_ast : type.class.name
      end,
      meta: meta,
    },
  ]
end