Sha256: 9c1d297e1fd8e6c6ba75f0e23938d5ed6b4a4721be3a06cb8f68875dbedaba88
Contents?: true
Size: 712 Bytes
Versions: 1
Compression:
Stored size: 712 Bytes
Contents
module Dry module Data class Compiler attr_reader :types def initialize(types) @types = types end def call(ast) visit(ast) end def visit(node, *args) send(:"visit_#{node[0]}", node[1], *args) end def visit_type(node) type, args = node if args send(:"visit_#{type}", args) else types[type] end end def visit_hash(node) constructor, schema = node types['hash'].public_send(constructor, schema.map { |key| visit(key) }.reduce(:merge)) end def visit_key(node) name, type = node { name => type } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-data-0.1.0 | lib/dry/data/compiler.rb |