13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/simpleadmin/decorators/fields_decorator.rb', line 13
def call(resources, table_name, table_fields)
resources.map do |resource|
resource_attributes = {}
table_fields.each do |table_field|
table_field_name, table_field_type = *table_field.values
if table_field_match?(table_field_type)
field_class = FIELDS_MAPPER[table_field_type]
resource_attributes[table_field_name] = field_class.new(table_name, table_field_name, resource).call
else
resource_attributes[table_field_name] = resource[table_field_name.to_sym]
end
end
resource_attributes
end
end
|