Skip to content

Commit 5d60d7e

Browse files
committed
Update to use Avo::Mappings
1 parent bff6416 commit 5d60d7e

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

lib/avo/concerns/has_field_discovery.rb

+2-34
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,18 @@ module Concerns
1313
module HasFieldDiscovery
1414
extend ActiveSupport::Concern
1515

16-
DEFAULT_COLUMN_NAMES_MAPPING = {
17-
id: {field: "id"},
18-
description: {field: "textarea"},
19-
gravatar: {field: "gravatar"},
20-
email: {field: "text"},
21-
password: {field: "password"},
22-
password_confirmation: {field: "password"},
23-
created_at: {field: "date_time"},
24-
updated_at: {field: "date_time"},
25-
stage: {field: "select"},
26-
budget: {field: "currency"},
27-
money: {field: "currency"},
28-
country: {field: "country"}
29-
}.freeze
30-
31-
DEFAULT_COLUMN_TYPES_MAPPING = {
32-
primary_key: {field: "id"},
33-
string: {field: "text"},
34-
text: {field: "textarea"},
35-
integer: {field: "number"},
36-
float: {field: "number"},
37-
decimal: {field: "number"},
38-
datetime: {field: "date_time"},
39-
timestamp: {field: "date_time"},
40-
time: {field: "date_time"},
41-
date: {field: "date"},
42-
binary: {field: "number"},
43-
boolean: {field: "boolean"},
44-
references: {field: "belongs_to"},
45-
json: {field: "code"}
46-
}.freeze
47-
4816
COLUMN_NAMES_TO_IGNORE = %i[
4917
encrypted_password reset_password_token reset_password_sent_at remember_created_at password_digest
5018
].freeze
5119

5220
class_methods do
5321
def column_names_mapping
54-
@column_names_mapping ||= DEFAULT_COLUMN_NAMES_MAPPING.dup
22+
@column_names_mapping ||= Avo::Mappings::NAMES_MAPPING.dup
5523
.merge(Avo.configuration.column_names_mapping || {})
5624
end
5725

5826
def column_types_mapping
59-
@column_types_mapping ||= DEFAULT_COLUMN_TYPES_MAPPING.dup
27+
@column_types_mapping ||= Avo::Mappings::FIELDS_MAPPING.dup
6028
.merge(Avo.configuration.column_types_mapping || {})
6129
end
6230
end

0 commit comments

Comments
 (0)