Fix memoized subject from context description another way

The other method gave a strange compiler error when running specs.
Something to do with "K" not having an inspect method.

In /usr/share/crystal/src/hash.cr:1826:13

 1826 | key.inspect(io)
            ^------
Error: undefined method 'inspect' for K
This commit is contained in:
Michael Miller 2020-02-16 19:50:20 -07:00
parent 86c8d6549a
commit 3aaab0e74f

View file

@ -24,17 +24,7 @@ module Spectator
{{what}}
end
@%wrapper : ::Spectator::TypedValueWrapper({{what}})?
def subject(*args)
if (wrapper = @%wrapper)
wrapper.value
else
described_class.new(*args).tap do |value|
@%wrapper = ::Spectator::TypedValueWrapper.new(value)
end
end
end
subject { described_class.new }
{% else %}
def _spectator_implicit_subject(*args)
{{what}}