Sha256: 29f1adea266841717b4153d031c46ef04a2092a1c404b9f1ffbbeb6c55a0b98c

Contents?: true

Size: 740 Bytes

Versions: 99

Compression:

Stored size: 740 Bytes

Contents

module Souls
  module Api
    module Generate
      ## Generate Model
      def self.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(<<~TEXT)
            class #{class_name.camelize} < ActiveRecord::Base
            end
          TEXT
        end
        puts(Paint % ["Created file! : %{white_text}", :green, { white_text: [file_path.to_s, :white] }])
        file_path
      rescue StandardError => e
        raise(StandardError, e)
      end
    end
  end
end

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
souls-0.44.6 lib/souls/api/generate/model.rb
souls-0.44.5 lib/souls/api/generate/model.rb
souls-0.44.4 lib/souls/api/generate/model.rb
souls-0.44.3 lib/souls/api/generate/model.rb
souls-0.44.2 lib/souls/api/generate/model.rb
souls-0.44.1 lib/souls/api/generate/model.rb
souls-0.44.0 lib/souls/api/generate/model.rb
souls-0.43.0 lib/souls/api/generate/model.rb
souls-0.42.1 lib/souls/api/generate/model.rb
souls-0.42.0 lib/souls/api/generate/model.rb
souls-0.41.3 lib/souls/api/generate/model.rb
souls-0.41.2 lib/souls/api/generate/model.rb
souls-0.41.1 lib/souls/api/generate/model.rb
souls-0.41.0 lib/souls/api/generate/model.rb
souls-0.40.3 lib/souls/api/generate/model.rb
souls-0.40.2 lib/souls/api/generate/model.rb
souls-0.40.1 lib/souls/api/generate/model.rb
souls-0.40.0 lib/souls/api/generate/model.rb
souls-0.39.0 lib/souls/api/generate/model.rb
souls-0.38.6 lib/souls/api/generate/model.rb