Class: ApplicationPolicy::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/rockstart/authorization/pundit/templates/app/policies/application_policy.rb

Overview

Scope filter used to limit access to resources

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Returns a new instance of Scope.



62
63
64
65
# File 'lib/generators/rockstart/authorization/pundit/templates/app/policies/application_policy.rb', line 62

def initialize(user, scope)
  @user = user || User.new
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



60
61
62
# File 'lib/generators/rockstart/authorization/pundit/templates/app/policies/application_policy.rb', line 60

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user.



60
61
62
# File 'lib/generators/rockstart/authorization/pundit/templates/app/policies/application_policy.rb', line 60

def user
  @user
end

Instance Method Details

#resolveObject



67
68
69
# File 'lib/generators/rockstart/authorization/pundit/templates/app/policies/application_policy.rb', line 67

def resolve
  scope.none
end