Module: Aker::Rails::Application
- Defined in:
- lib/aker/rails/application.rb
Overview
A mixin for the rails application controller. Provides global aker integration, but does not enforce any authentication or authorization requirements. (See SecuredController for one way to enforce authentication and authorization.)
This module is automatically mixed into the application controller when the plugin is initialized.
Class Method Summary collapse
-
.included(controller_class) ⇒ void
Sets up the aker global infrastructure and helpers in the application controller.
Instance Method Summary collapse
-
#current_user ⇒ Aker::User?
Exposes the logged-in user (if any) to the application.
-
#permit?(*groups, &block) ⇒ Boolean, ...
(also: #permit)
Aids group-level authorization.
Class Method Details
.included(controller_class) ⇒ void
This method returns an undefined value.
Sets up the aker global infrastructure and helpers in the application controller.
19 20 21 22 23 |
# File 'lib/aker/rails/application.rb', line 19 def self.included(controller_class) controller_class.class_eval do helper_method :current_user, :permit?, :permit end end |
Instance Method Details
#current_user ⇒ Aker::User?
Exposes the logged-in user (if any) to the application.
This method is also available to views (i.e., it is a helper).
31 32 33 |
# File 'lib/aker/rails/application.rb', line 31 def current_user request.env['aker.check'].user end |
#permit?(*groups, &block) ⇒ Boolean, ... Also known as: permit
Aids group-level authorization. It is safe to call this method without checking that there is a logged in user first.
This method delegates directly to Aker::Rack::Facade#permit?; see the documentation for that method for more information.
This method is also available to views (i.e., it is a helper).
45 46 47 |
# File 'lib/aker/rails/application.rb', line 45 def permit?(*groups, &block) request.env['aker.check'].permit?(*groups, &block) end |