Class: Parse::Authorization::Resolved

Inherits:
Struct
  • Object
show all
Defined in:
lib/parse/authorization.rb

Overview

The outcome of resolving a caller. user_id is the _User.objectId owning the session, or nil for an anonymous caller. role_names is a Set of bare role names (no role: prefix) the user inherits permissions from.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#role_namesObject

Returns the value of attribute role_names

Returns:

  • (Object)

    the current value of role_names



110
111
112
# File 'lib/parse/authorization.rb', line 110

def role_names
  @role_names
end

#user_idObject

Returns the value of attribute user_id

Returns:

  • (Object)

    the current value of user_id



110
111
112
# File 'lib/parse/authorization.rb', line 110

def user_id
  @user_id
end

Instance Method Details

#anonymous?Boolean

Returns true for the anonymous case.

Returns:

  • (Boolean)

    true for the anonymous case.



123
124
125
# File 'lib/parse/authorization.rb', line 123

def anonymous?
  user_id.nil? || user_id.empty?
end

#permission_stringsArray<String>

The canonical _rperm / _wperm permission-string set for this caller. Always includes "*". Includes user_id when present, and "role:#{name}" for each inherited role.

Returns:



115
116
117
118
119
120
# File 'lib/parse/authorization.rb', line 115

def permission_strings
  out = ["*"]
  out << user_id if user_id && !user_id.empty?
  role_names.each { |name| out << "role:#{name}" if name && !name.empty? }
  out.uniq
end