mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Rework let and subject to allow super
This addresses https://gitlab.com/arctic-fox/spectator/issues/32
This commit is contained in:
parent
35928133a9
commit
b95cf5693b
1 changed files with 4 additions and 4 deletions
|
@ -897,7 +897,7 @@ module Spectator::DSL
|
||||||
# Block variant.
|
# Block variant.
|
||||||
|
|
||||||
# Create a block that returns the value.
|
# Create a block that returns the value.
|
||||||
let!(%value) {{block}}
|
let!({{name.id}}) {{block}}
|
||||||
|
|
||||||
# Wrapper to hold the value.
|
# Wrapper to hold the value.
|
||||||
# This will be nil if the value hasn't been referenced yet.
|
# This will be nil if the value hasn't been referenced yet.
|
||||||
|
@ -913,12 +913,12 @@ module Spectator::DSL
|
||||||
# Unwrap it from the wrapper variable.
|
# Unwrap it from the wrapper variable.
|
||||||
# Here we use typeof to get around the issue
|
# Here we use typeof to get around the issue
|
||||||
# that the macro has no idea what type the value is.
|
# that the macro has no idea what type the value is.
|
||||||
wrapper.unsafe_as(::Spectator::Internals::TypedValueWrapper(typeof(%value))).value
|
wrapper.unsafe_as(::Spectator::Internals::TypedValueWrapper(typeof(previous_def))).value
|
||||||
else
|
else
|
||||||
# The value isn't cached,
|
# The value isn't cached,
|
||||||
# Construct it and store it in the wrapper.
|
# Construct it and store it in the wrapper.
|
||||||
%value.tap do |value|
|
previous_def.tap do |value|
|
||||||
@%wrapper = ::Spectator::Internals::TypedValueWrapper(typeof(%value)).new(value)
|
@%wrapper = ::Spectator::Internals::TypedValueWrapper(typeof(previous_def)).new(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue