Class: Authority::Authorizer
- Inherits:
-
Object
- Object
- Authority::Authorizer
- Defined in:
- lib/authority/authorizer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
The base Authorizer class, from which all the authorizers in an app will descend.
Class Method Summary collapse
-
.default(adjective, user, options = {}) ⇒ Object
Whitelisting approach: anything not specified will be forbidden.
Instance Method Summary collapse
-
#default(adjective, user, options = {}) ⇒ Object
the instance default method calls the class default method.
-
#initialize(resource) ⇒ Authorizer
constructor
A new instance of Authorizer.
Constructor Details
#initialize(resource) ⇒ Authorizer
Returns a new instance of Authorizer.
12 13 14 |
# File 'lib/authority/authorizer.rb', line 12 def initialize(resource) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
The base Authorizer class, from which all the authorizers in an app will descend. Provides the authorizer with both class and instance methods like ‘updatable_by?(user)`. Exactly which methods get defined is determined from `config.abilities`; the class is evaluated after any user-supplied config block is run in order to make that possible.
10 11 12 |
# File 'lib/authority/authorizer.rb', line 10 def resource @resource end |
Class Method Details
.default(adjective, user, options = {}) ⇒ Object
Whitelisting approach: anything not specified will be forbidden
17 18 19 |
# File 'lib/authority/authorizer.rb', line 17 def self.default(adjective, user, = {}) false end |
Instance Method Details
#default(adjective, user, options = {}) ⇒ Object
the instance default method calls the class default method
22 23 24 25 |
# File 'lib/authority/authorizer.rb', line 22 def default(adjective, user, = {}) = self.class.send(:user_and_maybe_options, user, ) self.class.send(:"#{adjective}_by?", *) end |