module Strongbolt::Configuration

Public Class Methods

access_denied(*args, &block) click to toggle source

Allows to configure what happens when the access is denied, or call the block that has been given

The block access denied receives as arguments:

user, instance, action, request_path
# File lib/strongbolt/configuration.rb, line 66
def self.access_denied(*args, &block)
  if block.present?
    @@access_denied_block = block
  elsif defined?(@@access_denied_block)
    @@access_denied_block.call(*args)
  end
end
add_tenant(tenant) click to toggle source

Adds a tenant if not in the list

# File lib/strongbolt/configuration.rb, line 51
def self.add_tenant(tenant)
  tenant = tenant.constantize if tenant.is_a? String
  unless @@tenants.any? { |m| m.name == tenant.name }
    tenant.send :tenant
    @@tenants << tenant
  end
end
default_capabilities() click to toggle source
# File lib/strongbolt/configuration.rb, line 106
def self.default_capabilities
  @@default_capabilities
end
default_capabilities=(list) click to toggle source
# File lib/strongbolt/configuration.rb, line 100
def self.default_capabilities=(list)
  @@default_capabilities = list.inject([]) do |capabilities, hash|
    capabilities.concat Capability.from_hash(hash)
  end
end
models=(models) click to toggle source

Allows to set Capability Models list

# File lib/strongbolt/configuration.rb, line 77
def self.models=(models)
  Strongbolt::Capability.add_models models
end
skip_controller_authorization_for(*controllers) click to toggle source

Controllers to skip controller authorization check ups

# File lib/strongbolt/configuration.rb, line 84
def self.skip_controller_authorization_for(*controllers)
  ActiveSupport.on_load :action_controller do
    controllers.each do |controller|
      begin
        "#{controller.camelize}Controller".constantize.send :skip_controller_authorization
      rescue NameError
        raise NameError, "Controller #{controller} doesn't correspond to a valid controller name"
      end
    end
  end
end
tenants() click to toggle source

Returns the tenants

# File lib/strongbolt/configuration.rb, line 44
def self.tenants
  @@tenants
end
tenants=(tenants) click to toggle source
# File lib/strongbolt/configuration.rb, line 36
def self.tenants=(tenants)
  @@tenants = []
  [*tenants].each { |t| add_tenant t }
end
user_class_constant() click to toggle source

Returns the constantize version of user class

# File lib/strongbolt/configuration.rb, line 22
def self.user_class_constant
  self.user_class.constantize
end