Class: SyncMachineGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/sync_machine_generator.rb

Overview

Generate SyncMachine files.

Instance Method Summary collapse

Instance Method Details

#append_subscribe_to_initializerObject



31
32
33
34
35
36
37
# File 'lib/generators/sync_machine_generator.rb', line 31

def append_subscribe_to_initializer
  initializer_path = "config/initializers/sync_machines.rb"
  create_file(initializer_path, "") unless File.exist?(initializer_path)
  append_to_file(
    initializer_path, "#{class_name}::ChangeListener.subscribe\n"
  )
end

#create_change_listener_fileObject



25
26
27
28
29
# File 'lib/generators/sync_machine_generator.rb', line 25

def create_change_listener_file
  template(
    "change_listener.rb", "app/services/#{file_path}/change_listener.rb"
  )
end

#create_ensure_publication_worker_fileObject



18
19
20
21
22
23
# File 'lib/generators/sync_machine_generator.rb', line 18

def create_ensure_publication_worker_file
  template(
    "ensure_publication_worker.rb",
    "app/workers/#{file_path}/ensure_publication_worker.rb"
  )
end

#create_find_subjects_worker_fileObject



11
12
13
14
15
16
# File 'lib/generators/sync_machine_generator.rb', line 11

def create_find_subjects_worker_file
  template(
    "find_subjects_worker.rb",
    "app/workers/#{file_path}/find_subjects_worker.rb"
  )
end