Sha256: d96e5fb15a0384d08de5b1e9d6e4d61d9ca8598b4ca938c0307216c860ccde87

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 Bytes

Contents

module Stationed
  module Generators
    module Plugins
      module Pundit
        def self.prepended(base)
          base.class_option :pundit,
            type: :boolean,
            default: true,
            desc: 'Include and configure Pundit for authorization'
        end

        def finish_template
          return super unless options[:pundit]
          gem 'pundit'
          copy_file 'pundit.rb', 'spec/support/pundit.rb'
          copy_file 'authorization.rb', 'app/controllers/concerns/authorization.rb'
          inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController', "\n  include Authorization\n\n"
          super
        end

        def run_bundle
          super
          return unless options[:pundit]
          generate 'pundit:install'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
stationed-0.6.0 lib/stationed/generators/plugins/pundit.rb
stationed-0.5.0 lib/stationed/generators/plugins/pundit.rb
stationed-0.4.0 lib/stationed/generators/plugins/pundit.rb
stationed-0.3.0 lib/stationed/generators/plugins/pundit.rb
stationed-0.2.0 lib/stationed/generators/plugins/pundit.rb
stationed-0.1.0 lib/stationed/generators/plugins/pundit.rb