Module: PolicyHelper
- Defined in:
- app/helpers/policy_helper.rb
Constant Summary collapse
- PERMISSION_ALIASES =
{ list: :index }.with_indifferent_access.freeze
Instance Method Summary collapse
Instance Method Details
#can?(*actions) ⇒ Boolean
6 7 8 9 10 |
# File 'app/helpers/policy_helper.rb', line 6 def can?(*actions) model = actions.pop.to_s = policy(model.singularize.classify.constantize) actions.all? { |action| .send((action)) } end |
#map_policy_permission(action) ⇒ Object
12 13 14 |
# File 'app/helpers/policy_helper.rb', line 12 def (action) "#{(PERMISSION_ALIASES[action] || action)}?" end |