I’m trying to do something along the lines of below to achieve type-safe setting of attributes via a double splat
class ORM
  @field1 : String
  @field2 : Int32
  ATTRS = {
    :field1 => String,
    :field2 => Int32,
  }
  macro finished
    __generate_assigner__
  end
  macro __generate_assigner__
    def assign_attributes(**args)
      {% for name, type in ATTRS %}
        {% key = name.id.symbolize %}
        if args.has_key?({{key}})
          @{{name.id}} = args[{{key}}]
        end
      {% end %}
    end
  end
end
This won’t work, as the compile-time key presence check of the NamedTuple prevents this. https://carc.in/#/r/9gsq
Any ideas on how to achieve this, or something similar?
Thanks crystal massive 