Sha256: 8d8f4b6a1fe50d133a5266be05aec6cdeec0d384610a420bb1f09710551be96b

Contents?: true

Size: 667 Bytes

Versions: 8

Compression:

Stored size: 667 Bytes

Contents

module Souls
  module Generate
    class << self
      ## Generate Model
      def model class_name: "souls"
        file_dir = "./app/models/"
        FileUtils.mkdir_p file_dir unless Dir.exist? file_dir
        file_path = "#{file_dir}#{class_name.singularize}.rb"
        return "Model already exist! #{file_path}" if File.exist? file_path
        File.open(file_path, "w") do |f|
          f.write <<~EOS
            class #{class_name.camelize} < ActiveRecord::Base
            end
          EOS
        end
        puts "Created file! : #{file_path}"
        file_path
      rescue StandardError => e
        raise StandardError, e
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
souls-0.22.9 lib/souls/generate/model.rb
souls-0.22.8 lib/souls/generate/model.rb
souls-0.22.7 lib/souls/generate/model.rb
souls-0.22.6 lib/souls/generate/model.rb
souls-0.22.5 lib/souls/generate/model.rb
souls-0.22.4 lib/souls/generate/model.rb
souls-0.22.3 lib/souls/generate/model.rb
souls-0.22.2 lib/souls/generate/model.rb