Sha256: 8335b1fe599907c4c2799e3ed337cac9e1e77ba651cc7ca2e48ee753daacbf18

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Souls
  module Worker
    module Generate
      class << self
        def mutation(class_name: "csv_export")
          file_dir = "./app/graphql/mutations/"
          FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir)
          file_path = "#{file_dir}#{class_name.singularize}_job.rb"
          raise(StandardError, "Mailer already exist! #{file_path}") if File.exist?(file_path)

          File.open(file_path, "w") do |f|
            f.write(<<~TEXT)
              module Mutations
                class #{class_name.camelize}Job < BaseMutation
                  description "Job Description"
                  field :response, String, null: false

                  def resolve
                    # Define Job Here

                    { response: "Job queued!" }
                  rescue StandardError => e
                    GraphQL::ExecutionError.new(e.to_s)
                  end
              end
            TEXT
          end
          puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
          file_path
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
souls-0.33.2 lib/souls/worker/generate/mutation.rb