Module: LcpRuby::ConditionServices::Impersonating

Defined in:
lib/lcp_ruby/condition_services/impersonating.rb

Overview

Returns true when the current user is being impersonated (i.e. ‘current_user` is wrapped in `LcpRuby::ImpersonatedUser`). Typical usage:

- "Stop impersonating" menu item: visible_when: { service: impersonating }
- Yellow impersonation banner shown above the layout: same condition

The condition-evaluator contract passes only ‘context: { current_user: … }` (no controller — see ConditionEvaluator#evaluate_service), so detection inspects the user object rather than the controller’s session. This works from any view/helper that has ‘current_user` available (mailers, cache warm-up, anywhere LcpRuby::Current.user is set).

Class Method Summary collapse

Class Method Details

.call(_record, context: {}) ⇒ Object



17
18
19
20
# File 'lib/lcp_ruby/condition_services/impersonating.rb', line 17

def call(_record, context: {}, **)
  user = context[:current_user]
  user.is_a?(LcpRuby::ImpersonatedUser)
end