Skip to content

Commit 6db630a

Browse files
committed
Revert "Make fetchable_fields more like other field overrides"
This reverts commit cdc5ef0.
1 parent 7b3cdff commit 6db630a

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ end
188188
##### Fetchable Attributes
189189

190190
By default all attributes are assumed to be fetchable. The list of fetchable attributes can be filtered by overriding
191-
the `self.fetchable_fields` method.
191+
the `fetchable_fields` method.
192192

193193
Here's an example that prevents guest users from seeing the `email` field:
194194

@@ -198,7 +198,7 @@ class AuthorResource < JSONAPI::Resource
198198
model_name 'Person'
199199
has_many :posts
200200

201-
def self.fetchable_fields(context)
201+
def fetchable_fields
202202
if (context[:current_user].guest)
203203
super - [:email]
204204
else

lib/jsonapi/resource.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def replace_fields(field_data)
105105
end
106106
end
107107

108+
# Override this on a resource instance to override the fetchable keys
108109
def fetchable_fields
109-
self.class.fetchable_fields(context)
110+
self.class.fields
110111
end
111112

112113
# Override this on a resource to customize how the associated records
@@ -440,11 +441,6 @@ def method_missing(method, *args)
440441
end
441442
# :nocov:
442443

443-
# Override in your resource to filter the fetchable keys
444-
def fetchable_fields(_context = nil)
445-
fields
446-
end
447-
448444
# Override in your resource to filter the updatable keys
449445
def updatable_fields(_context = nil)
450446
_updatable_relationships | _attributes.keys - [:id]

0 commit comments

Comments
 (0)