Sha256: bf53602b672e7490e01ee655139e55fc8d11110576a75502b4b5c849514a005e

Contents?: true

Size: 844 Bytes

Versions: 7

Compression:

Stored size: 844 Bytes

Contents

authorization_framework = {
  pundit: ->{
    gather_gem 'pundit'

    after(:gem_install) do
      application_controller = "app/controllers/application_controller.rb"
      gsub_file application_controller, "protect_from_forgery" do
        "include Pundit\n  protect_from_forgery"
      end
      generate "pundit:install"
    end

    if get(:admin_mode)
      after(:admin_install) do
        initializer = "config/initializers/active_admin.rb"
        gsub_file initializer, /# config\.authorization_adapter =[^\n]+\n/ do
          "config.authorization_adapter = ActiveAdmin::PunditAdapter\n"
        end

        template "assets/active_admin/pundit_page_policy.rb", "app/policies/active_admin/page_policy.rb"
      end
    end
  }
}

if get(:authorization)
  instance_exec(&(authorization_framework[get(:authorization)] || ->{ }))
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
potassium-1.2.3 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.2.2 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.2.1 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.2.0 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.1.0 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.0.1 lib/potassium/templates/application/recipes/pundit.rb
potassium-1.0.0 lib/potassium/templates/application/recipes/pundit.rb