Sha256: ff2a23e56550dec443462ef016148b872deff2c7d39ad34a4f87f2a9d32d6c88

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 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}.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} < BaseMutation
                  description "Job Description"
                  field :response, String, null: false

                  def resolve
                    # Define Job Here

                    { response: "Job done!" }
                  rescue StandardError => e
                    GraphQL::ExecutionError.new(e.to_s)
                  end
                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

9 entries across 9 versions & 1 rubygems

Version Path
souls-0.45.0 lib/souls/worker/generate/mutation.rb
souls-0.44.6 lib/souls/worker/generate/mutation.rb
souls-0.44.5 lib/souls/worker/generate/mutation.rb
souls-0.44.4 lib/souls/worker/generate/mutation.rb
souls-0.44.3 lib/souls/worker/generate/mutation.rb
souls-0.44.2 lib/souls/worker/generate/mutation.rb
souls-0.44.1 lib/souls/worker/generate/mutation.rb
souls-0.44.0 lib/souls/worker/generate/mutation.rb
souls-0.43.0 lib/souls/worker/generate/mutation.rb