Sha256: 858818225f1a890f943fbc0b3f46d0f553bed547be7c12b688cfe005ae65e9bf

Contents?: true

Size: 623 Bytes

Versions: 4

Compression:

Stored size: 623 Bytes

Contents

# frozen_string_literal: true

module Lifeform
  module Libraries
    class Default
      FORM_TAG = :form

      # @param form [LifeForm::Form]
      # @param field_definition [LifeForm::FieldDefinition]
      # @param attributes [Hash]
      # @return [Input]
      def self.object_for_field_definition(form, field_definition, attributes)
        type_classname = Lifeform::Form.send(:camelize, field_definition[:type])
        if const_defined?(type_classname)
          const_get(type_classname)
        else
          const_get(:Input)
        end.new(form, field_definition, **attributes)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lifeform-0.15.0 lib/lifeform/libraries/default.rb
lifeform-0.14.0 lib/lifeform/libraries/default.rb
lifeform-0.13.0 lib/lifeform/libraries/default.rb
lifeform-0.12.0 lib/lifeform/libraries/default.rb