Class: Parse::Constraint::ACLReadableByRoleConstraint

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

Overview

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

Find objects readable by Admin role (string - adds role: prefix)

Post.where(:ACL.readable_by_role => "Admin")

Find objects readable by Role object

Post.where(:ACL.readable_by_role => admin_role)

Find objects readable by multiple roles

Post.where(:ACL.readable_by_role => ["Admin", "Moderator"])

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns the compiled constraint using _rperm field.

Returns:

  • (Hash)

    the compiled constraint using _rperm field.



2723
2724
2725
2726
# File 'lib/parse/query/constraints.rb', line 2723

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

#readable_by_roleACLReadableByRoleConstraint

Examples:

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

Returns:



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

register :readable_by_role