base.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Sequence::Base
  3. # Defines the default attributes that will get returned for the sequence.
  4. # These can be overwritten by giving the :expecting key to a sequence process call.
  5. #
  6. # @example
  7. # Sequencer::Sequence::Example.expecting
  8. # # => [:result, :list]
  9. #
  10. # @return [Array<Symbol>] the list of expected result keys.
  11. def self.expecting
  12. []
  13. end
  14. # Defines the list of Units that form the sequence. The units will get
  15. # processed in the order they are defined in. The namespaces can be
  16. # absolute or without the `Sequencer::Unit` prefix.
  17. #
  18. # @example
  19. # Sequencer::Sequence::Example.sequence
  20. # # => ['Import::Example::Resource', 'Sequencer::Unit::Import::Model::Create', ...]
  21. #
  22. # @return [Array<String>] the list of units forming the sequence.
  23. def self.sequence
  24. raise "Missing implementation of '#{__method__}' method for '#{name}'"
  25. end
  26. # This is an internally used method that converts the defined sequence to a
  27. # Sequencer::Units instance which has special methods.
  28. #
  29. # @example
  30. # Sequencer::Sequence::Example.units
  31. # # => <Sequencer::Units @units=[....>
  32. #
  33. # @return [Object]
  34. def self.units
  35. Sequencer::Units.new(*sequence)
  36. end
  37. # @see .units
  38. def units
  39. self.class.units
  40. end
  41. end