Class: Pundit::Matchers::Configuration
- Inherits:
-
Object
- Object
- Pundit::Matchers::Configuration
- Defined in:
- lib/pundit/matchers.rb
Overview
Configuration class for Pundit Matchers.
Constant Summary collapse
- DEFAULT_USER_ALIAS =
The default user object value
:user
Instance Attribute Summary collapse
-
#default_user_alias ⇒ Symbol|String
The default user object in policies.
-
#user_aliases ⇒ Hash
Policy-specific user objects.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#user_alias(policy) ⇒ Symbol
Returns the user object for the given policy.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 |
# File 'lib/pundit/matchers.rb', line 38 def initialize @default_user_alias = DEFAULT_USER_ALIAS @user_aliases = {} end |
Instance Attribute Details
#default_user_alias ⇒ Symbol|String
The default user object in policies.
28 29 30 |
# File 'lib/pundit/matchers.rb', line 28 def default_user_alias @default_user_alias end |
#user_aliases ⇒ Hash
Policy-specific user objects.
36 37 38 |
# File 'lib/pundit/matchers.rb', line 36 def user_aliases @user_aliases end |
Instance Method Details
#user_alias(policy) ⇒ Symbol
Returns the user object for the given policy.
46 47 48 |
# File 'lib/pundit/matchers.rb', line 46 def user_alias(policy) user_aliases.fetch(policy.class.name, default_user_alias) end |