lib/yuuki/caller.rb in yuuki-0.1.5 vs lib/yuuki/caller.rb in yuuki-0.1.7

- old
+ new

@@ -75,13 +75,24 @@ # @param [Object] args arguments def run_select(proc_select, **args, &block) run_internal(runners.select(&proc_select), args, &block) end + # set whether to ignore ``tag not associated'' error + def ignore_tag_error(enabled: true) + @ignore_tag_error = enabled + end + # runs all methods with the specified tags # @param [Symbol] tags # @param [Object] args arguments def run_tag(*tags, **args, &block) + t = self.tags + tags.each do |e| + next if t.include?(e) + raise Yuuki::Error, "tag `#{e}` is not associated" unless @ignore_tag_error + warn "Yuuki Warning: tag `#{e}` is not associated" + end run_select(proc{|_method, meta| meta[:tags]&.intersect?(tags)}, **args, &block) end # runs the specific method # @param [Class, nil] klass