Sha256: 9ef35583b8e988e2b9b532a6de56561f891640dc178a987be8c81cb575683876

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

module Phlexi
  module Form
    module Options
      module InferredTypes
        private

        def infer_field_component
          return :select if choices
          
          case inferred_field_type
          when :string, :text
            infer_string_field_type || inferred_field_type
          when :integer, :float, :decimal
            :number
          when :json, :jsonb
            :text
          when :enum
            :select
          when :association
            association_reflection.polymorphic? ? :"polymorphic_#{association_reflection.macro}" : association_reflection.macro
          when :attachment, :binary
            :file
          when :citext
            infer_string_field_type || :string
          when :date, :time, :datetime, :boolean, :hstore
            inferred_field_type
          else
            :string
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phlexi-form-0.5.2 lib/phlexi/form/options/inferred_types.rb
phlexi-form-0.5.1 lib/phlexi/form/options/inferred_types.rb