Skip to content

Commit

Permalink
Rename original_scope to scope
Browse files Browse the repository at this point in the history
Doesn't feel like the qualification is necessary, falling back to the
term used in pundit docs/examples.
  • Loading branch information
solebared committed Feb 14, 2021
1 parent ccf0d31 commit dca3c31
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/policies/announcement_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def permitted_attributes

class Scope < ApplicationPolicy::Scope
def resolve
can_admin? ? original_scope : original_scope.published
can_admin? ? scope : scope.published
end
end
end
8 changes: 4 additions & 4 deletions app/policies/application_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def extract(context)
class Scope
include Utils

attr_reader :original_scope
attr_reader :scope

def initialize(context, original_scope)
def initialize(context, scope)
@user, @system_settings, @admin_param = extract context
@original_scope = original_scope
@scope = scope
end

# We default all permissions to false, and expect you to override as needed.
def resolve
original_scope.none
scope.none
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/policies/community_resource_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def permitted_attributes

class Scope < ApplicationPolicy::Scope
def resolve
can_admin? ? original_scope : original_scope.published
can_admin? ? scope : scope.published
end
end
end
6 changes: 3 additions & 3 deletions app/policies/person_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class Scope < Scope
def resolve
case
when can_admin?
original_scope.all
scope.all
when user.present?
original_scope.where(user_id: user.id)
scope.where(user_id: user.id)
else
original_scope.none
scope.none
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/policies/user_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ class Scope < Scope
def resolve
case
when can_admin?
original_scope.all
scope.all
when user.present?
original_scope.where(id: user.id)
scope.where(id: user.id)
else
original_scope.none
scope.none
end
end
end
Expand Down

0 comments on commit dca3c31

Please sign in to comment.