Class: Avo::Resources::DbConfig::ForceChangeType

Inherits:
BaseAction
  • Object
show all
Defined in:
app/avo/resources/db_config.rb

Constant Summary collapse

DEFAULT_VALUE_TYPES =
{
  "String" => "",
  "Integer" => 0,
  "Float" => 0.0,
  "Boolean" => false,
  "Array" => [],
  "Hash" => {},
  "NilClass" => nil
}

Instance Method Summary collapse

Instance Method Details

#fieldsObject



102
103
104
# File 'app/avo/resources/db_config.rb', line 102

def fields
  field :value_type, as: :select, options: DBConfig::Record::VALUE_TYPES
end

#handle(query:, fields:) ⇒ Object



116
117
118
119
# File 'app/avo/resources/db_config.rb', line 116

def handle(query:, fields:, **)
  query.first.update!(value_type: fields[:value_type], value: DEFAULT_VALUE_TYPES[fields[:value_type]])
  succeed "Type changed successfully."
end