Class: Parse::Constraint::ACLReadableByConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::ACLReadableByConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
A constraint for filtering objects based on ACL read permissions. This constraint queries the MongoDB _rperm field directly. Strings are used as exact permission values (user IDs or "role:RoleName" format).
For role-based filtering with automatic "role:" prefix, use readable_by_role instead.
Find objects readable by a specific user object (fetches user's roles automatically)
Post.where(:ACL.readable_by => user)
Find objects readable by exact permission strings (no prefix added)
Post.where(:ACL.readable_by => "user123") # User ID Post.where(:ACL.readable_by => "role:Admin") # Role with explicit prefix Post.where(:ACL.readable_by => ["user123", "role:Admin"])
Direct Known Subclasses
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint using _rperm field.
-
#readable_by ⇒ ACLReadableByConstraint
A registered method on a symbol to create the constraint.
-
#strict? ⇒ Boolean
Whether to compile an EXACT match (suppress the implicit public
"*"grant and the missing-field branch).
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint using _rperm field.
2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 |
# File 'lib/parse/query/constraints.rb', line 2893 def build # Use @value directly to preserve type information before # formatted_value converts to pointers. value = @value # "No permissions" intent (nil / [] / "none" / :none) matches # objects whose _rperm is an explicit empty array — master-key-only # documents. A missing _rperm is public (the opposite of "none"), so # {ACLPermissions.empty_pipeline} deliberately does NOT match it. return ACLPermissions.empty_pipeline(field: "_rperm") if ACLPermissions.empty_intent?(value) = ACLPermissions.collect(value) ACLPermissions.pipeline(, field: "_rperm", strict: strict?) end |
#readable_by ⇒ ACLReadableByConstraint
A registered method on a symbol to create the constraint.
2883 |
# File 'lib/parse/query/constraints.rb', line 2883 register :readable_by |
#strict? ⇒ Boolean
Returns whether to compile an EXACT match (suppress the
implicit public "*" grant and the missing-field branch).
Overridden by Parse::Constraint::ACLReadableByExactConstraint.
2888 2889 2890 |
# File 'lib/parse/query/constraints.rb', line 2888 def strict? false end |