Class: Dhall::Import::IntegrityCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/ast.rb

Defined Under Namespace

Classes: FailureException

Instance Method Summary collapse

Constructor Details

#initialize(protocol = :nocheck, data = nil) ⇒ IntegrityCheck



1113
1114
1115
1116
1117
1118
# File 'lib/dhall/ast.rb', line 1113

def initialize(protocol=:nocheck, data=nil)
  super(
    protocol: protocol,
    data:     data
  )
end

Instance Method Details

#as_jsonObject



1133
1134
1135
# File 'lib/dhall/ast.rb', line 1133

def as_json
  @protocol == :nocheck ? nil : [@protocol, @data]
end

#check(expr) ⇒ Object

Raises:



1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/dhall/ast.rb', line 1124

def check(expr)
  return expr if @protocol == :nocheck

  expr = expr.normalize
  return expr if expr.cache_key == to_s

  raise FailureException, "#{expr} does not match #{self}"
end

#to_sObject



1120
1121
1122
# File 'lib/dhall/ast.rb', line 1120

def to_s
  "#{@protocol}:#{@data}"
end