Sha256: 43855dd364e8754eb583aed213dbcd83dbd7b2316cc3f7332845890ad0b42104

Contents?: true

Size: 899 Bytes

Versions: 5

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

require "rails/generators"
require "rails/generators/migration"
require "rails/generators/active_record"

module Permisi
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path("templates", __dir__)

      def self.next_migration_number(path)
        ActiveRecord::Generators::Base.next_migration_number(path)
      end

      def create_initializer
        template "initializer.rb", "config/initializers/permisi.rb"
      end

      def create_migrations
        migration_template "migration.rb", "db/migrate/create_permisi_tables.rb", migration_version: migration_version
      end

      private

      def migration_version
        "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" if ActiveRecord.version.version > "5"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
permisi-0.1.5 lib/generators/permisi/install_generator.rb
permisi-0.1.4 lib/generators/permisi/install_generator.rb
permisi-0.1.3 lib/generators/permisi/install_generator.rb
permisi-0.1.2 lib/generators/permisi/install_generator.rb
permisi-0.1.1 lib/generators/permisi/install_generator.rb