class Pragma::Policy::Scope
Authorizes AR scopes and other relations by only returning the records accessible by the current user. Used, for instance, in index operations.
Attributes
context[R]
@!attribute [r] user
@return [Object] the user accessing the records
@!attribute [r] scope
@return [Object] the relation to use as a base
scope[R]
@!attribute [r] user
@return [Object] the user accessing the records
@!attribute [r] scope
@return [Object] the relation to use as a base
user[R]
@!attribute [r] user
@return [Object] the user accessing the records
@!attribute [r] scope
@return [Object] the relation to use as a base
Public Class Methods
new(user, scope)
click to toggle source
Initializes the scope.
@param user [Object] the user accessing the records @param scope [Object] the relation to use as a base
# File lib/pragma/policy/scope.rb, line 20 def initialize(user, scope) @user = user @scope = scope end
Public Instance Methods
resolve()
click to toggle source
Returns the records accessible by the given user.
@return [Object]
@abstract Override to implement retrieving the accessible records
# File lib/pragma/policy/scope.rb, line 30 def resolve fail NotImplementedError end
Private Instance Methods
policy_klass()
click to toggle source
# File lib/pragma/policy/scope.rb, line 36 def policy_klass Object.const_get(self.class.name.split('::')[0..-2].join('::')) end