Sha256: 9eb9cc14aae308651bd422e408cbbea381504b2908eaf9f155661334d31c814a

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

module Yattho
  # :nocov:
  # :nodoc:
  class FormComponents
    def self.from_input(input_klass)
      Class.new(Yattho::Component) do
        @input_klass = input_klass

        class << self
          attr_reader :input_klass
        end

        def initialize(**system_arguments, &block)
          @system_arguments = system_arguments
          @block = block
        end

        def call
          builder = Yattho::Forms::Builder.new(
            nil, nil, __vc_original_view_context, {}
          )

          input = self.class.input_klass.new(
            builder: builder,
            form: nil,
            **@system_arguments,
            &@block
          )

          input.to_component.render_in(__vc_original_view_context) { content }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 lib/yattho/form_components.rb
yattho_view_components-0.0.1 lib/yattho/form_components.rb