base.rb 1.4 KB

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