Move conditional into context macro

This commit is contained in:
Michael Miller 2018-09-19 19:29:33 -06:00
parent fe81341e1a
commit d679c356fd

View file

@ -18,7 +18,9 @@ module Spectator
::Spectator::Definitions::GROUPS[{{@type.stringify}}]
)
_described_class {{what}}
{% if what.is_a?(Path) || what.is_a?(Generic) %}
_described_class {{what}}
{% end %}
{{block.body}}
end
@ -121,16 +123,14 @@ module Spectator
end
macro _described_class(what)
{% if what.is_a?(Path) || what.is_a?(Generic) %}
def described_class
{{what}}.tap do |thing|
raise "#{thing} must be a type name to use #described_class or #subject,\
but it is a #{typeof(thing)}" unless thing.is_a?(Class)
end
def described_class
{{what}}.tap do |thing|
raise "#{thing} must be a type name to use #described_class or #subject,\
but it is a #{typeof(thing)}" unless thing.is_a?(Class)
end
end
_implicit_subject
{% end %}
_implicit_subject
end
macro _implicit_subject