lib/nxt_schema/node/schema.rb in nxt_schema-1.0.1 vs lib/nxt_schema/node/schema.rb in nxt_schema-1.0.2
- old
+ new
@@ -1,36 +1,36 @@
module NxtSchema
module Node
class Schema < Node::Base
def call
apply_on_evaluators
- child_applications # build applications here so we can access them even when invalid
+ child_nodes # build nodes here so we can access them even when invalid
return self if maybe_evaluator_applies?
coerce_input
return self unless valid?
flag_missing_keys
apply_additional_keys_strategy
- child_applications.each do |key, child|
- current_application = child.call
+ child_nodes.each do |key, child|
+ current_node = child.call
- if !current_application.valid?
- merge_errors(current_application)
+ if !current_node.valid?
+ merge_errors(current_node)
else
- output[key] = current_application.output
+ output[key] = current_node.output
end
end
transform_keys
register_as_coerced_when_no_errors
run_validations
self
end
- delegate :[], to: :child_applications
+ delegate :[], to: :child_nodes
private
def transform_keys
transformer = node.key_transformer
@@ -86,25 +86,25 @@
def restrict_additional_keys?
node.additional_keys_strategy == :restrict
end
- def child_applications
- @child_applications ||= begin
+ def child_nodes
+ @child_nodes ||= begin
keys.inject({}) do |acc, key|
- child_application = build_child_application(key)
- acc[key] = child_application if child_application.present?
+ child_node = build_child_node(key)
+ acc[key] = child_node if child_node.present?
acc
end
end
end
- def build_child_application(key)
+ def build_child_node(key)
sub_node = node.sub_nodes[key]
return unless sub_node.present?
- value = input_has_key?(input, key) ? input[key] : MissingInput.new
- sub_node.build_application(input: value, context: context, parent: self)
+ value = input_has_key?(input, key) ? input[key] : Undefined.new
+ sub_node.build_node(input: value, context: context, parent: self)
end
def input_has_key?(input, key)
input.respond_to?(:key?) && input.key?(key)
end