module RatatuiRuby::Widgets::CoerceableWidget

Mixin that provides DWIM hash coercion for widget classes.

When users call ‘tui.table(hash)` instead of `tui.table(**hash)`, Ruby’s ‘…` forwarding passes the Hash as a positional argument, causing cryptic TypeErrors at the Rust FFI boundary.

This mixin provides a ‘coerce_args` class method that detects this pattern and automatically splats the hash into keyword arguments.

Behavior

Usage

class Table < Data.define(:rows, :widths, ...)
  include CoerceableWidget
end

# In WidgetFactories:
def table(first = nil, **kwargs)
  Widgets::Table.coerce_args(first, kwargs)
end