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.
3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 |
# File 'lib/parse/query/constraints.rb', line 3626 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.
3616 |
# File 'lib/parse/query/constraints.rb', line 3616 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.
3621 3622 3623 |
# File 'lib/parse/query/constraints.rb', line 3621 def strict? false end |