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

Instance Method Details

#policy(object) ⇒ Object



28
29
30
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 28

def policy(object)
  Policy.for(current_user, object)
end

#verify_policy(record) ⇒ Object



37
38
39
40
41
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 37

def verify_policy(record)
  return true if policy(record).public_send("#{action_name}?")

  raise PagesCore::NotAuthorized
end

#verify_policy_with_proc(controller, record) ⇒ Object



32
33
34
35
# File 'app/controllers/concerns/pages_core/policies_helper.rb', line 32

def verify_policy_with_proc(controller, record)
  record = controller.instance_eval(&record) if record.is_a?(Proc)
  verify_policy(record)
end