base.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. module Import
  3. class Base
  4. # Checks if the backend is active.
  5. #
  6. # @example
  7. # Import::ExampleBackend.active?
  8. # #=> true
  9. #
  10. # return [Boolean]
  11. def self.active?
  12. true
  13. end
  14. # Checks if the backend is able to get queued by the Scheduler.
  15. #
  16. # @example
  17. # Import::ExampleBackend.queueable?
  18. # #=> true
  19. #
  20. # return [Boolean]
  21. def self.queueable?
  22. true
  23. end
  24. # Checks if the backend is able to get rescheduled in case the Scheduler
  25. # got (re-)started while this ImportJob was running. Defaults to false.
  26. #
  27. # @example
  28. # instance = Import::LDAP.new(import_job)
  29. # instance.reschedule?(delayed_job)
  30. # #=> false
  31. #
  32. # return [false]
  33. def reschedule?(_delayed_job)
  34. false
  35. end
  36. # Initializes a new instance with a stored reference to the ImportJob.
  37. #
  38. # @example
  39. # instance = Import::ExampleBackend.new(import_job)
  40. #
  41. # return [Import::ExampleBackend]
  42. def initialize(import_job)
  43. @import_job = import_job
  44. end
  45. # Starts the life or dry run import of the backend.
  46. #
  47. # @example
  48. # instance = Import::ExampleBackend.new(import_job)
  49. #
  50. # @raise [RuntimeError] Raised if the implementation of this mandatory method is missing
  51. #
  52. # return [nil]
  53. def start
  54. raise "Missing implementation if the 'start' method."
  55. end
  56. end
  57. end