Class: Recipes::Pundit

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/potassium/recipes/pundit.rb

Instance Method Summary collapse

Instance Method Details

#askObject



2
3
4
5
6
7
# File 'lib/potassium/recipes/pundit.rb', line 2

def ask
  if get(:authentication).present?
    use_pundit = answer(:pundit) { Ask.confirm("Do you want to use Pundit for authorization?") }
    set(:authorization, use_pundit)
  end
end

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/potassium/recipes/pundit.rb', line 9

def create
  if selected?(:authorization)
    run_pundit_installer
    recipe = self

    if selected?(:admin_mode)
      after(:admin_install) do
        recipe.install_admin_pundit
      end
    end
  end
end

#installObject



22
23
24
25
26
27
# File 'lib/potassium/recipes/pundit.rb', line 22

def install
  run_pundit_installer

  active_admin = load_recipe(:admin)
  install_admin_pundit if active_admin.installed?
end

#install_admin_punditObject



33
34
35
36
# File 'lib/potassium/recipes/pundit.rb', line 33

def install_admin_pundit
  configure_active_admin_initializer
  copy_policies
end

#installed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/potassium/recipes/pundit.rb', line 29

def installed?
  gem_exists?(/pundit/)
end