base.rb 1.5 KB

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