From d679c356fdf3ba2d8f2b68e442c19f75c70bb93b Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 19 Sep 2018 19:29:33 -0600 Subject: [PATCH] Move conditional into context macro --- src/spectator/dsl/structure_dsl.cr | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index 0ef24c5..c15ddb9 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -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