Module: Strongbolt::Configuration
- Defined in:
- lib/strongbolt/configuration.rb
Defined Under Namespace
Classes: DefaultLogger
Constant Summary collapse
- @@user_class =
'User'
- @@logger =
DefaultLogger.new
- @@tenants =
Sets the tenants of the application
[]
- @@default_capabilities =
Default permissions
[]
Class Method Summary collapse
-
.access_denied(*args, &block) ⇒ Object
Allows to configure what happens when the access is denied, or call the block that has been given.
-
.add_tenant(tenant) ⇒ Object
Adds a tenant if not in the list.
- .default_capabilities ⇒ Object
- .default_capabilities=(list) ⇒ Object
-
.models=(models) ⇒ Object
Allows to set Capability Models list.
-
.skip_controller_authorization_for(*controllers) ⇒ Object
Controllers to skip controller authorization check ups.
-
.tenants ⇒ Object
Returns the tenants.
- .tenants=(tenants) ⇒ Object
-
.user_class_constant ⇒ Object
Returns the constantize version of user class.
Class Method Details
.access_denied(*args, &block) ⇒ Object
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
66 67 68 69 70 71 72 |
# 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) ⇒ Object
Adds a tenant if not in the list
51 52 53 54 55 56 57 |
# 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 ⇒ Object
106 107 108 |
# File 'lib/strongbolt/configuration.rb', line 106 def self.default_capabilities @@default_capabilities end |
.default_capabilities=(list) ⇒ Object
100 101 102 103 104 |
# 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) ⇒ Object
Allows to set Capability Models list
77 78 79 |
# File 'lib/strongbolt/configuration.rb', line 77 def self.models=(models) Strongbolt::Capability.add_models models end |
.skip_controller_authorization_for(*controllers) ⇒ Object
Controllers to skip controller authorization check ups
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/strongbolt/configuration.rb', line 84 def self.(*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 ⇒ Object
Returns the tenants
44 45 46 |
# File 'lib/strongbolt/configuration.rb', line 44 def self.tenants @@tenants end |
.tenants=(tenants) ⇒ Object
36 37 38 39 |
# File 'lib/strongbolt/configuration.rb', line 36 def self.tenants=(tenants) @@tenants = [] [*tenants].each { |t| add_tenant t } end |
.user_class_constant ⇒ Object
Returns the constantize version of user class
22 23 24 |
# File 'lib/strongbolt/configuration.rb', line 22 def self.user_class_constant self.user_class.constantize end |