2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Common
|
|
|
|
module Mapping
|
|
|
|
class FlatKeys < Sequencer::Unit::Base
|
|
|
|
include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped
|
2018-04-26 07:07:30 +00:00
|
|
|
prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
|
|
|
|
|
|
|
|
skip_any_action
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
uses :resource
|
2018-04-26 07:07:30 +00:00
|
|
|
provides :mapped
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
def process
|
|
|
|
provide_mapped do
|
|
|
|
mapped
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def mapped
|
2020-03-18 09:56:37 +00:00
|
|
|
@mapped ||= begin
|
|
|
|
resource_with_indifferent_access = resource.with_indifferent_access
|
2022-01-03 07:21:16 +00:00
|
|
|
mapping.symbolize_keys.to_h do |source, local|
|
2020-03-18 09:56:37 +00:00
|
|
|
[local, resource_with_indifferent_access[source]]
|
2022-01-03 07:21:16 +00:00
|
|
|
end.with_indifferent_access
|
2020-03-18 09:56:37 +00:00
|
|
|
end
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def mapping
|
|
|
|
raise "Missing implementation of '#{__method__}' method for '#{self.class.name}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|