Sha256: c60147a41f6fa7cce88b78c58b9578b134ec812ac43008176fdd4b23957c9b19

Contents?: true

Size: 724 Bytes

Versions: 6

Compression:

Stored size: 724 Bytes

Contents

# Policy Lookup

Action Policy tries to automatically infer policy class from the target using the following _probes_:

1. If the target responds to `policy_class`, then use it;
2. If the target's class responds to `policy_class`, then use it;
3. If the target's class responds to `policy_name`, then use `#{target.class.policy_name}Policy`;
4. Otherwise, use `#{target.class.name}Policy`.

> \* [Namespaces](namespaces.md) could be also be considered when `namespace` option is set.

You can call `ActionPolicy.lookup(record, options)` to infer policy class for the record.

When no policy class is found, an `ActionPolicy::NotFound` error is raised.

You can [customize lookup](custom_lookup_chain.md) logic if necessary.

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
action_policy-0.2.0 docs/lookup_chain.md
action_policy-0.1.4 docs/lookup_chain.md
action_policy-0.1.3 docs/lookup_chain.md
action_policy-0.1.2 docs/lookup_chain.md
action_policy-0.1.1 docs/lookup_chain.md
action_policy-0.1.0 docs/lookup_chain.md