Class: Course::Duplication::BaseService

Inherits:
Object
  • Object
show all
Defined in:
app/services/course/duplication/base_service.rb

Overview

Provides a base service to use the Duplicator Object. To use, define different duplication modes which inherits from this base service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseService

Base constructor for the service object.

This also sets [email protected]+ as the Duplicator object for the duplication service.

Parameters:

  • options (Hash) (defaults to: {})

    The options to be sent to the Duplicator object.

Options Hash (options):

  • :time_shift (String)

    The time shift for timestamps between the courses.

  • :mode (Symbol)

    The duplication mode provided by the service.

Raises:

  • (KeyError)

    When the options do not include time_shift and/or mode.


16
17
18
19
20
21
# File 'app/services/course/duplication/base_service.rb', line 16

def initialize(options = {})
  @options = options
  @duplicator = initialize_duplicator(options)
  return if options[:time_shift] && options[:mode]
  raise KeyError, 'Options must include both time_shift and mode'
end

Instance Attribute Details

#duplicatorObject (readonly)

Returns the value of attribute duplicator


6
7
8
# File 'app/services/course/duplication/base_service.rb', line 6

def duplicator
  @duplicator
end