Sha256: f9939b255ae13fa0624533d33c409af4c62ebb5a4ce026a27a49e81846caa252
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require_relative "../../utils/project" module DSL ## # Invoke macro # @param name (String) Macro name # @param input (Hash) Macro params def macro(name, input = {}) macros = Project.value[:macros] unless macros[name] log("Macro #{name} not found!", :error) return end input.each_pair { |k, v| set(k, v) } errors = [] macros[name][:args].each do |i| errors << i if get(i) == "NODATA" end if errors.count > 0 log("Macro #{name} => required params #{errors.join(",")}", :error) else instance_eval(¯os[name][:block]) end input.each_pair { |k, v| unset(k) } end # If a method call is missing, then: # * delegate to concept parent. # * Invoke macro (assert) def method_missing(method, args = {}) a = method.to_s if a.start_with?("_") return instance_eval("get(:#{a[1, a.size - 1]})", __FILE__, __LINE__) end return macro a[6, a.size], args if a[0, 6] == "macro_" macro a, args end def respond_to_missing?(method, *) true end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
teuton-2.8.0 | lib/teuton/case/dsl/macro.rb |