Class: AnyVali::LiteralSchema

Inherits:
Schema
  • Object
show all
Defined in:
lib/anyvali/schemas/literal_schema.rb

Constant Summary

Constants inherited from Schema

Schema::RESERVED_METADATA_KEYS

Instance Attribute Summary collapse

Attributes inherited from Schema

#coerce_config, #constraints, #custom_validators, #default_value, #has_default, #kind, #metadata

Instance Method Summary collapse

Methods inherited from Schema

#coerce, #default, #describe, #export, #parse, #portable?, #refine, #safe_parse, type_name, #with_metadata

Constructor Details

#initialize(value:, **kwargs) ⇒ LiteralSchema

Returns a new instance of LiteralSchema.



7
8
9
10
# File 'lib/anyvali/schemas/literal_schema.rb', line 7

def initialize(value:, **kwargs)
  @literal_value = value
  super(kind: "literal", **kwargs)
end

Instance Attribute Details

#literal_valueObject (readonly)

Returns the value of attribute literal_value.



5
6
7
# File 'lib/anyvali/schemas/literal_schema.rb', line 5

def literal_value
  @literal_value
end

Instance Method Details

#to_nodeObject



12
13
14
15
16
# File 'lib/anyvali/schemas/literal_schema.rb', line 12

def to_node
  node = super
  node["value"] = @literal_value
  node
end