Class: NxtSchema::Template::Schema
- Includes:
- HasSubNodes
- Defined in:
- lib/nxt_schema/template/schema.rb
Constant Summary collapse
Instance Attribute Summary
Attributes inherited from Base
#additional_keys_strategy, #configuration, #context, #key_transformer, #maybe_evaluators, #meta, #name, #on_evaluators, #options, #parent_node, #path, #root_node, #type, #type_system, #validations
Instance Method Summary collapse
-
#initialize(name:, type: DEFAULT_TYPE, parent_node:, **options, &block) ⇒ Schema
constructor
A new instance of Schema.
- #omnipresent(name, node_or_type_of_node, **options, &block) ⇒ Object
- #optional(name, node_or_type_of_node, **options, &block) ⇒ Object
Methods included from HasSubNodes
#[], #add_sub_node, #any_of, #collection, #ensure_sub_nodes_present, #node, #schema, #sub_nodes
Methods inherited from Base
#apply, #apply!, #build_node, #default, #maybe, #omnipresent?, #on, #optional?, #root_node?, #validate, #validate_with
Constructor Details
#initialize(name:, type: DEFAULT_TYPE, parent_node:, **options, &block) ⇒ Schema
Returns a new instance of Schema.
8 9 10 11 |
# File 'lib/nxt_schema/template/schema.rb', line 8 def initialize(name:, type: DEFAULT_TYPE, parent_node:, **, &block) super ensure_sub_nodes_present end |
Instance Method Details
#omnipresent(name, node_or_type_of_node, **options, &block) ⇒ Object
17 18 19 |
# File 'lib/nxt_schema/template/schema.rb', line 17 def omnipresent(name, node_or_type_of_node, **, &block) node(name, node_or_type_of_node, **.merge(omnipresent: true), &block) end |
#optional(name, node_or_type_of_node, **options, &block) ⇒ Object
13 14 15 |
# File 'lib/nxt_schema/template/schema.rb', line 13 def optional(name, node_or_type_of_node, **, &block) node(name, node_or_type_of_node, **.merge(optional: true), &block) end |