Skip to content

Commit d86768a

Browse files
committed
Improve readability of get_skipped_builtin_actions.
1 parent b0561d2 commit d86768a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/rest_framework/utils.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ def self.get_skipped_builtin_actions(controller_class, singular)
4646
RESTFramework::BUILTIN_ACTIONS.keys - (singular ? [ :index ] : [])
4747
) + RESTFramework::BUILTIN_MEMBER_ACTIONS.keys
4848

49+
# Skip all builtin actions for controllers without a model, since the builtin actions assume a
50+
# model is present.
4951
return candidates unless controller_class.model
5052

53+
# Skip actions if there is no method defined or if the action is explicitly excluded.
5154
exclude = controller_class.excluded_actions&.to_set || Set.new
52-
candidates.reject do |action|
53-
controller_class.method_defined?(action) && !exclude.include?(action)
55+
candidates.select do |action|
56+
!controller_class.method_defined?(action) || exclude.include?(action)
5457
end
5558
end
5659

0 commit comments

Comments
 (0)