Class: ActiveScaffold::Tableless::Column

Inherits:
ActiveRecord::ConnectionAdapters::Column
  • Object
show all
Defined in:
lib/active_scaffold/tableless.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, default, type, null = true) ⇒ Column

rubocop:disable Style/OptionalBooleanParameter,Metrics/ParameterLists



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_scaffold/tableless.rb', line 26

def initialize(name, default, type, null = true, *, **) # rubocop:disable Style/OptionalBooleanParameter,Metrics/ParameterLists
  if Rails.version >= '8.1'
    if type.is_a?(Symbol)
      cast_type = ActiveRecord::Type.lookup(type)
    else
       = ActiveRecord::Base.connection.send :fetch_type_metadata, type
      cast_type = ActiveRecord::Type.lookup(.type)
    end
    super(name, cast_type, default, , null, *, **)
  else
     = ActiveRecord::Base.connection.send :fetch_type_metadata, type.to_s
    super(name, default, , null, *, **)
  end
end