Class: IronAdmin::Import::ColumnMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_admin/import/column_mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, current_user: nil) ⇒ ColumnMapper

Returns a new instance of ColumnMapper.



6
7
8
9
# File 'lib/iron_admin/import/column_mapper.rb', line 6

def initialize(resource_class, current_user: nil)
  @resource_class = resource_class
  @current_user = current_user
end

Instance Method Details

#map_headers(headers) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/iron_admin/import/column_mapper.rb', line 11

def map_headers(headers)
  candidates = field_candidates

  headers.each_with_object({}) do |header, mapping|
    field = candidates[normalize(header)]
    mapping[header] = field.name if field
  end
end