base.rb 612 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class FormUpdater::ApplyValue::Base
  3. attr_reader :context, :data, :dirty_fields, :result
  4. def initialize(context:, data:, dirty_fields:, result:)
  5. @context = context
  6. @data = data
  7. @dirty_fields = dirty_fields
  8. @result = result
  9. end
  10. def can_handle_field?(field:, field_attribute:)
  11. false
  12. end
  13. def apply_value(field:, config:)
  14. return if skip_dirty_field?(field:)
  15. map_value(field:, config:)
  16. end
  17. def skip_dirty_field?(field:)
  18. dirty_fields&.include?(field) && data[field].present?
  19. end
  20. end