module Ariadne::ViewComponent::HTMLAttrs
def accepts_html_attributes_for(name, **defaults, &block)
def accepts_html_attributes_for(name, **defaults, &block) html_attribute_accessors[name] = defaults name = name.to_sym method_name = :"#{name}_attrs" ivar_name = :"@#{method_name}" attr_reader(method_name) mod = Module.new do define_method(:initialize) do |**options| value = self.class.default_html_attributes_for(name).deep_merge!(options.delete(method_name).to_h) super(**options) instance_exec(value, &block) if block instance_variable_set(ivar_name, value) end end prepend(mod) end