class Dhall::ExpressionVisitor
Constants
- ExpressionArray
- ExpressionHash
Public Class Methods
new(&block)
click to toggle source
# File lib/dhall/normalize.rb, line 15 def initialize(&block) @block = block end
Public Instance Methods
one_visit(value)
click to toggle source
# File lib/dhall/normalize.rb, line 26 def one_visit(value) case value when Expression @block[value] when ExpressionArray value.map(&@block) when ExpressionHash Hash[value.map { |k, v| [k, v.nil? ? v : @block[v]] }.sort] end end
visit(expr)
click to toggle source
# File lib/dhall/normalize.rb, line 19 def visit(expr) expr.to_h.each_with_object({}) do |(attr, value), h| result = one_visit(value) h[attr] = result if result end end