attribute.rb 632 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Common::Provider::Attribute < Sequencer::Unit::Base
  3. def process
  4. return if ignore?
  5. state.provide(attribute, value)
  6. end
  7. private
  8. def attribute
  9. @attribute ||= provides
  10. end
  11. def provides
  12. provides_list = self.class.provides
  13. raise "Only single provide attribute possible for class #{self.class.name}" if provides_list.size != 1
  14. provides_list.first
  15. end
  16. def value
  17. @value ||= send(attribute)
  18. end
  19. def ignore?
  20. # don't store nil values which are default anyway
  21. value.nil?
  22. end
  23. end