Class: Parse::Constraint::ACLWritableByRoleConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/parse/query/constraints.rb

Overview

A constraint for filtering objects writable by specific role names. Automatically adds "role:" prefix to role names.

# Find objects writable by Admin role (string - adds role: prefix) Post.where(:ACL.writable_by_role => "Admin")

# Find objects writable by Role object Post.where(:ACL.writable_by_role => admin_role)

# Find objects writable by multiple roles Post.where(:ACL.writable_by_role => ["Admin", "Moderator"])

Direct Known Subclasses

ACLWritableByRoleExactConstraint

Instance Method Summary collapse

Instance Method Details

#build ⇒ Hash

Returns the compiled constraint using _wperm field.

Returns:

  • (Hash) —

    the compiled constraint using _wperm field.



3778
3779
3780
3781
# File 'lib/parse/query/constraints.rb', line 3778

def build
  permissions = ACLPermissions.collect_role_only(@value)
  ACLPermissions.pipeline(permissions, field: "_wperm", strict: strict?)
end

#strict? ⇒ Boolean

Returns whether to compile an EXACT match. Overridden by Parse::Constraint::ACLWritableByRoleExactConstraint.

Returns:



3773
3774
3775
# File 'lib/parse/query/constraints.rb', line 3773

def strict?
  false
end

#writable_by_role ⇒ ACLWritableByRoleConstraint

Examples:

q.where :ACL.writable_by_role => "Admin"

Returns:



3769
# File 'lib/parse/query/constraints.rb', line 3769

register :writable_by_role