Class: ActiveAdmin::AuthorizationAdapter
- Inherits:
-
Object
- Object
- ActiveAdmin::AuthorizationAdapter
- Defined in:
- lib/active_admin/authorization_adapter.rb
Overview
Active Admin’s default authorization adapter. This adapter returns true for all requests to ‘#authorized?`. It should be the starting point for implementing your own authorization adapter.
To view an example subclass, check out ‘ActiveAdmin::CanCanAdapter`
Direct Known Subclasses
Defined Under Namespace
Classes: NormalizedMatcher
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#authorized?(action, subject = nil) ⇒ Boolean
Returns true of false depending on if the user is authorized to perform the action on the subject.
-
#initialize(resource, user) ⇒ AuthorizationAdapter
constructor
Initialize a new authorization adapter.
-
#scope_collection(collection, action = Auth::READ) ⇒ ActiveRecord::Relation
A hook method for authorization libraries to scope the collection.
Constructor Details
#initialize(resource, user) ⇒ AuthorizationAdapter
Initialize a new authorization adapter. This happens on each and every request to a controller.
35 36 37 38 |
# File 'lib/active_admin/authorization_adapter.rb', line 35 def initialize(resource, user) @resource = resource @user = user end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
22 23 24 |
# File 'lib/active_admin/authorization_adapter.rb', line 22 def resource @resource end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
22 23 24 |
# File 'lib/active_admin/authorization_adapter.rb', line 22 def user @user end |
Instance Method Details
#authorized?(action, subject = nil) ⇒ Boolean
Returns true of false depending on if the user is authorized to perform the action on the subject.
54 55 56 |
# File 'lib/active_admin/authorization_adapter.rb', line 54 def (action, subject = nil) true end |
#scope_collection(collection, action = Auth::READ) ⇒ ActiveRecord::Relation
A hook method for authorization libraries to scope the collection. By default, we just return the same collection. The returned scope is used as the starting point for all queries to the db in the controller.
71 72 73 |
# File 'lib/active_admin/authorization_adapter.rb', line 71 def scope_collection(collection, action = Auth::READ) collection end |