Rework let and subject to allow super

This addresses https://gitlab.com/arctic-fox/spectator/issues/32
This commit is contained in:
Michael Miller 2019-10-24 20:47:48 -06:00
parent 3dd691a990
commit e035afa85f

View file

@ -1,17 +1,17 @@
module Spectator module Spectator
module DSL module DSL
macro let(name, &block) macro let(name, &block)
def %value
{{block.body}}
end
@%wrapper : ::Spectator::ValueWrapper? @%wrapper : ::Spectator::ValueWrapper?
def {{name.id}}
{{block.body}}
end
def {{name.id}} def {{name.id}}
if (wrapper = @%wrapper) if (wrapper = @%wrapper)
wrapper.as(::Spectator::TypedValueWrapper(typeof(%value))).value wrapper.as(::Spectator::TypedValueWrapper(typeof(previous_def))).value
else else
%value.tap do |value| previous_def.tap do |value|
@%wrapper = ::Spectator::TypedValueWrapper.new(value) @%wrapper = ::Spectator::TypedValueWrapper.new(value)
end end
end end