Class: Macros::CurrentUser::Set
- Defined in:
- lib/macros/current_user/set.rb
Overview
Sets the current_user in the context.
Instance Method Summary collapse
-
#call(ctx) ⇒ Object
Sets the current user in the context.
-
#initialize(key: :model) ⇒ Macro::CurrentUser::Set
constructor
Step macro instance.
Methods inherited from Base
Constructor Details
#initialize(key: :model) ⇒ Macro::CurrentUser::Set
Returns step macro instance.
11 12 13 |
# File 'lib/macros/current_user/set.rb', line 11 def initialize(key: :model) @key = key end |
Instance Method Details
#call(ctx) ⇒ Object
Sets the current user in the context
17 18 19 20 21 22 |
# File 'lib/macros/current_user/set.rb', line 17 def call(ctx, **) return false unless ctx[@key] return false unless VALID_CURRENT_USER_CLASS_NAMES.include? ctx[@key].class.name.demodulize ctx[:current_user] = ctx[@key] end |