Class: RailsAsyncMethodsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/rails_async_methods_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_abstract_jobObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/rails_async_methods_generator.rb', line 3

def create_abstract_job
  file_path = "app/jobs/rails_async_methods/abstract_job.rb"
  return if File.exist? file_path

  create_file file_path,
    <<~FILE
      class RailsAsyncMethods::AbstractJob < ApplicationJob
        queue_as :default

        def perform(receiver, method, *args, **kwargs)
          receiver.public_send(method, *args, **kwargs)
        end
      end
    FILE
end