Module: PagesCore::PoliciesHelper
- Extended by:
- ActiveSupport::Concern
- Included in:
- BaseController
- Defined in:
- app/controllers/concerns/pages_core/policies_helper.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #policy(object) ⇒ Object
- #verify_policy(record) ⇒ Object
- #verify_policy_with_proc(controller, record) ⇒ Object
Instance Method Details
#policy(object) ⇒ Object
26 27 28 |
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 26 def policy(object) Policy.for(current_user, object) end |
#verify_policy(record) ⇒ Object
35 36 37 38 |
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 35 def verify_policy(record) return true if policy(record).public_send(action_name + "?") raise PagesCore::NotAuthorized end |
#verify_policy_with_proc(controller, record) ⇒ Object
30 31 32 33 |
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 30 def verify_policy_with_proc(controller, record) record = controller.instance_eval(&record) if record.is_a?(Proc) verify_policy(record) end |