Module: Rbacan::ViewHelpers
- Defined in:
- lib/rbacan/view_helpers.rb
Instance Method Summary collapse
-
#authorized?(permission, context: nil, &block) ⇒ Boolean
Renders the block only when the host authorization adapter permits it.
Instance Method Details
#authorized?(permission, context: nil, &block) ⇒ Boolean
Renders the block only when the host authorization adapter permits it.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rbacan/view_helpers.rb', line 4 def (, context: nil, &block) allowed = if Rbacan.legacy_mode current_user&.can?(.to_s) else Rbacan.( user: current_user, permission: , context: context || ) end return unless allowed capture(&block) if block_given? end |