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

Returns a new instance of IntegrityCheck.



1198
1199
1200
1201
1202
1203
# File 'lib/dhall/ast.rb', line 1198

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

Instance Method Details

#as_jsonObject



1218
1219
1220
# File 'lib/dhall/ast.rb', line 1218

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

#check(expr) ⇒ Object

Raises:



1209
1210
1211
1212
1213
1214
1215
1216
# File 'lib/dhall/ast.rb', line 1209

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



1205
1206
1207
# File 'lib/dhall/ast.rb', line 1205

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