class Avo::BaseResource

def fill_model(model, params, extra_params: [])

def fill_model(model, params, extra_params: [])
  # Map the received params to their actual fields
  fields_by_database_id = get_field_definitions
    .reject do |field|
      field.computed
    end
    .map do |field|
      [field.database_id.to_s, field]
    end
    .to_h
  # Write the field values
  params.each do |key, value|
    field = fields_by_database_id[key]
    next unless field.present?
    model = field.fill_field model, key, value, params
  end
  # Write the user configured extra params to the model
  if extra_params.present?
    # Let Rails fill in the rest of the params
    model.assign_attributes params.permit(extra_params)
  end
  model
end