Class: AnyVali::TupleSchema
- Defined in:
- lib/anyvali/schemas/tuple_schema.rb
Constant Summary
Constants inherited from Schema
Schema::RESERVED_METADATA_KEYS
Instance Attribute Summary collapse
-
#element_schemas ⇒ Object
readonly
Returns the value of attribute element_schemas.
Attributes inherited from Schema
#coerce_config, #constraints, #custom_validators, #default_value, #has_default, #kind, #metadata
Instance Method Summary collapse
-
#initialize(elements:, **kwargs) ⇒ TupleSchema
constructor
A new instance of TupleSchema.
- #to_node ⇒ Object
Methods inherited from Schema
#coerce, #default, #describe, #export, #parse, #portable?, #refine, #safe_parse, type_name, #with_metadata
Constructor Details
#initialize(elements:, **kwargs) ⇒ TupleSchema
Returns a new instance of TupleSchema.
7 8 9 10 |
# File 'lib/anyvali/schemas/tuple_schema.rb', line 7 def initialize(elements:, **kwargs) @element_schemas = elements.freeze super(kind: "tuple", **kwargs) end |
Instance Attribute Details
#element_schemas ⇒ Object (readonly)
Returns the value of attribute element_schemas.
5 6 7 |
# File 'lib/anyvali/schemas/tuple_schema.rb', line 5 def element_schemas @element_schemas end |
Instance Method Details
#to_node ⇒ Object
12 13 14 15 16 |
# File 'lib/anyvali/schemas/tuple_schema.rb', line 12 def to_node node = super node["elements"] = @element_schemas.map(&:to_node) node end |