From e74437c2796b820856a447c6157311c340fa2679 Mon Sep 17 00:00:00 2001 From: Hibariya Date: Wed, 30 Oct 2024 13:54:40 +0000 Subject: [PATCH] Allow Orthoses::Constant to skip modules --- lib/orthoses/constant.rb | 1 + lib/orthoses/constant_test.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/orthoses/constant.rb b/lib/orthoses/constant.rb index 333487c..8020604 100644 --- a/lib/orthoses/constant.rb +++ b/lib/orthoses/constant.rb @@ -30,6 +30,7 @@ def call cache[[current, const]] = true if val.kind_of?(Module) + next unless @if.nil? || @if.call(current, const, val, nil) will_add_key_and_content << [Utils.module_name(val), nil] next end diff --git a/lib/orthoses/constant_test.rb b/lib/orthoses/constant_test.rb index 16cb177..ba6897d 100644 --- a/lib/orthoses/constant_test.rb +++ b/lib/orthoses/constant_test.rb @@ -13,6 +13,7 @@ module Bar end class Baz CONST = 3 + IGNORE_ME = Class.new end end @@ -21,7 +22,7 @@ def test_constant(t) Orthoses::Utils.new_store.tap do |store| store["ConstantTest"] end - }, strict: true).call + }, strict: true, if: -> (current, const, val, rbs) { const.to_s != "IGNORE_ME" }).call unless store.length == 8 t.error("expect 8 constant decls, but got #{store.length}")