Class: Parse::Constraint::ACLWritableByConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::ACLWritableByConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
A constraint for filtering objects based on ACL write permissions. This constraint queries the MongoDB _wperm field directly. Strings are used as exact permission values (user IDs or "role:RoleName" format).
For role-based filtering with automatic "role:" prefix, use writable_by_role instead.
# Find objects writable by a specific user object (fetches user's roles automatically) Post.where(:ACL.writable_by => user)
# Find objects writable by exact permission strings (no prefix added) Post.where(:ACL.writable_by => "user123") # User ID Post.where(:ACL.writable_by => "role:Admin") # Role with explicit prefix Post.where(:ACL.writable_by => ["user123", "role:Admin"])
Direct Known Subclasses
ACLWritableByExactConstraint, WritableByConstraint, WriteableByConstraint
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint using _wperm field.
-
#strict? ⇒ Boolean
Whether to compile an EXACT match.
-
#writable_by ⇒ ACLWritableByConstraint
A registered method on a symbol to create the constraint.
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint using _wperm field.
3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 |
# File 'lib/parse/query/constraints.rb', line 3728 def build # Use @value directly to preserve type information before # formatted_value converts to pointers. value = @value # "No permissions" intent (nil / [] / "none" / :none) — see # {ACLReadableByConstraint#build}. return ACLPermissions.empty_pipeline(field: "_wperm") if ACLPermissions.empty_intent?(value) = ACLPermissions.collect(value) ACLPermissions.pipeline(, field: "_wperm", strict: strict?) end |
#strict? ⇒ Boolean
Returns whether to compile an EXACT match. Overridden by Parse::Constraint::ACLWritableByExactConstraint.
3723 3724 3725 |
# File 'lib/parse/query/constraints.rb', line 3723 def strict? false end |
#writable_by ⇒ ACLWritableByConstraint
A registered method on a symbol to create the constraint.
3719 |
# File 'lib/parse/query/constraints.rb', line 3719 register :writable_by |