Skip to content

Commit 14a4adb

Browse files
committed
Remove obsolete records_for method
This method is no longer used in JR 0.10
1 parent 89d8752 commit 14a4adb

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

lib/jsonapi/authorization/pundit_scoped_resource.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,6 @@ def records(options = {})
1111
::Pundit.policy_scope!(user_context, super)
1212
end
1313
end
14-
15-
def records_for(association_name)
16-
record_or_records = @model.public_send(association_name)
17-
relationship = fetch_relationship(association_name)
18-
19-
case relationship
20-
when JSONAPI::Relationship::ToOne
21-
record_or_records
22-
when JSONAPI::Relationship::ToMany
23-
user_context = JSONAPI::Authorization.configuration.user_context(context)
24-
::Pundit.policy_scope!(user_context, record_or_records)
25-
else
26-
raise "Unknown relationship type #{relationship.inspect}"
27-
end
28-
end
29-
30-
private
31-
32-
def fetch_relationship(association_name)
33-
relationships = self.class._relationships.select do |_k, v|
34-
v.relation_name(context: context) == association_name
35-
end
36-
if relationships.empty?
37-
nil
38-
else
39-
relationships.values.first
40-
end
41-
end
4214
end
4315
end
4416
end

0 commit comments

Comments
 (0)