flat_keys.rb 816 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Common::Mapping::FlatKeys < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped
  4. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  5. skip_any_action
  6. uses :resource
  7. provides :mapped
  8. def process
  9. provide_mapped do
  10. mapped
  11. end
  12. end
  13. private
  14. def mapped
  15. @mapped ||= begin
  16. resource_with_indifferent_access = resource.with_indifferent_access
  17. mapping.symbolize_keys.to_h do |source, local|
  18. [local, resource_with_indifferent_access[source]]
  19. end.with_indifferent_access
  20. end
  21. end
  22. def mapping
  23. raise "Missing implementation of '#{__method__}' method for '#{self.class.name}'"
  24. end
  25. end