Class: HunterPolicy::Scope

Inherits:
Scope
  • Object
show all
Defined in:
app/policies/hunter_policy.rb

Overview

When working with a list of records, this class can limit access

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Returns a new instance of Scope.


24
25
26
27
# File 'app/policies/hunter_policy.rb', line 24

def initialize(user, scope)
  @user = user
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope


22
23
24
# File 'app/policies/hunter_policy.rb', line 22

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user


22
23
24
# File 'app/policies/hunter_policy.rb', line 22

def user
  @user
end

Instance Method Details

#resolveObject


29
30
31
32
# File 'app/policies/hunter_policy.rb', line 29

def resolve
  return scope.none if @user.nil?
  scope.all
end