Module: ActionPolicy::LookupChain

Defined in:
lib/action_policy/graphiti/lookup_chain.rb

Overview

Allow policies to be found not only for ActiveRecords but for Graphiti Resources (<EntityName>Resource) too

Constant Summary collapse

INFER_FROM_RESOURCE_CLASS =
lambda do |resource, namespace: nil, strict_namespace: false, **_options|
  policy_name = Graphiti::PolicyNameInferrer.infer(resource)
  lookup_within_namespace(policy_name, namespace, strict: strict_namespace)
end
INFER_FOR_BASE_FROM_POLYMORPHIC_RESOURCE_CLASS =
lambda do |resource, namespace: nil, strict_namespace: false, **_options|
  policy_name = Graphiti::PolicyNameInferrer.infer_polymorphic(resource)
  lookup_within_namespace(policy_name, namespace, strict: strict_namespace)
end