Class: Checken::UserProxy
- Inherits:
-
Object
- Object
- Checken::UserProxy
- Defined in:
- lib/checken/user_proxy.rb
Overview
The user proxy class sits on top of a user and provides the methods that checken needs. You can write your own proxy or use the default. If you use the default you’ll need to make sure that the users you provide implement the methods this proxy will call.
All interactions between checken and a user will happen via a proxy. This default class is a useful benchmark list of how your user should behave.
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#contexts ⇒ Array<Symbol>
An array of contexts that this user is part of.
-
#description ⇒ String
Return a suitable description for this user for use in log files.
-
#granted_permissions ⇒ Array<String>
Returns an array of permissions that this user has permission to use.
-
#initialize(user) ⇒ UserProxy
constructor
A new instance of UserProxy.
Constructor Details
#initialize(user) ⇒ UserProxy
Returns a new instance of UserProxy.
14 15 16 |
# File 'lib/checken/user_proxy.rb', line 14 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
11 12 13 |
# File 'lib/checken/user_proxy.rb', line 11 def user @user end |
Instance Method Details
#contexts ⇒ Array<Symbol>
An array of contexts that this user is part of
40 41 42 43 44 45 46 |
# File 'lib/checken/user_proxy.rb', line 40 def contexts if @user.respond_to?(:checken_contexts) @user.checken_contexts else [] end end |
#description ⇒ String
Return a suitable description for this user for use in log files
21 22 23 24 25 26 27 |
# File 'lib/checken/user_proxy.rb', line 21 def description if @user.respond_to?(:id) "#{@user.class}##{@user.id}" else "#{@user.class}" end end |
#granted_permissions ⇒ Array<String>
Returns an array of permissions that this user has permission to use.
33 34 35 |
# File 'lib/checken/user_proxy.rb', line 33 def @user. end |