Class: Superform::Field::Kit

Inherits:
Object
  • Object
show all
Defined in:
lib/superform/field.rb

Overview

High-performance Kit proxy that wraps field methods with form.render calls. Uses Ruby class hooks to define methods at the class level for maximum speed:

  • Methods are defined once per Field class, not per Kit instance

  • True Ruby methods with full VM optimization (no method_missing overhead)

  • ~125x faster Kit instantiation compared to instance-level dynamic methods

  • Each Field subclass gets its own isolated Kit class with true isolation:

    • Methods are copied at subclass creation time, not inherited dynamically

    • Adding methods to a parent Field class won’t affect existing subclass Kits

    • Perfect for library design where you don’t want parent changes affecting subclasses

Instance Method Summary collapse

Constructor Details

#initialize(field:, form:) ⇒ Kit

Returns a new instance of Kit.



77
78
79
80
# File 'lib/superform/field.rb', line 77

def initialize(field:, form:)
  @field = field
  @form = form
end