lib/dry/data/compiler.rb in dry-data-0.5.0 vs lib/dry/data/compiler.rb in dry-data-0.5.1
- old
+ new
@@ -15,28 +15,38 @@
send(:"visit_#{node[0]}", node[1], *args)
end
def visit_type(node)
type, args = node
+ meth = :"visit_#{type.gsub('.', '_')}"
- if respond_to?(:"visit_#{type}")
- send(:"visit_#{type}", args)
+ if respond_to?(meth)
+ send(meth, args)
else
registry[type]
end
end
def visit_sum(node)
node.map { |type| visit(type) }.reduce(:|)
end
+ def visit_array(node)
+ registry['array'].member(call(node))
+ end
+
+ def visit_form_array(node)
+ registry['form.array'].member(call(node))
+ end
+
def visit_hash(node)
constructor, schema = node
registry['hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge))
end
- def visit_array(node)
- registry['array'].member(call(node))
+ def visit_form_hash(node)
+ constructor, schema = node
+ registry['form.hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge))
end
def visit_key(node)
name, types = node
{ name => visit(types) }