Sha256: 3ac6ba250d4a4887f103992c69d3241e5c1554e6645c0168bf9afbc6f65634e0

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'boring_generators/generator_helper'

module Boring
  module Cancancan
    class InstallGenerator < Rails::Generators::Base
      include BoringGenerators::GeneratorHelper

      desc "Adds cancancan gem to the application"

      class_option :skip_config,
                   type: :boolean,
                   default: false,
                   desc: "Skip adding cancancan configuration. Default to false"

      def add_cancancan_gem
        say "Adding cancancan gem", :green
        check_and_install_gem("cancancan")
        bundle_install
      end

      def configure_cancancan
        return if options[:skip_config]

        say "Configuring cancancan", :green

        Bundler.with_unbundled_env do
          run "bundle exec rails g cancan:ability"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
boring_generators-0.15.0 lib/generators/boring/cancancan/install/install_generator.rb
boring_generators-0.14.0 lib/generators/boring/cancancan/install/install_generator.rb