Sha256: 8b5e2c596f1918da33e4b931dadf52fc259c2c4b356a6f9284abd25d5070b9d8

Contents?: true

Size: 1004 Bytes

Versions: 2

Compression:

Stored size: 1004 Bytes

Contents

# frozen_string_literal: true

module Kingsman
  module Generators
    module OrmHelpers
      def model_contents
        buffer = <<-CONTENT
  # Include default kingsman modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  kingsman :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable

CONTENT
        buffer
      end

      private

      def model_exists?
        File.exist?(File.join(destination_root, model_path))
      end

      def migration_exists?(table_name)
        Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_kingsman_to_#{table_name}.rb$/).first
      end

      def migration_path
        if Jets.version >= '5.0.3'
          db_migrate_path
        else
          @migration_path ||= File.join("db", "migrate")
        end
      end

      def model_path
        @model_path ||= File.join("app", "models", "#{file_path}.rb")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kingsman-0.1.1 lib/generators/kingsman/orm_helpers.rb
kingsman-0.1.0 lib/generators/kingsman/orm_helpers.rb