Skip to content

Commit e36f87a

Browse files
authored
fix: mark BaseResource as abstract in resource manager initialization (#3893)
This change moves the abstract resource flag to the ResourceManager's initialize method, ensuring that the BaseResource is treated as abstract without requiring developers to modify the BaseResource class directly.
1 parent 4810007 commit e36f87a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/avo/base_resource.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Avo
22
class BaseResource < Avo::Resources::Base
3-
abstract_resource!
4-
53
# Users can override this class to add custom methods for all resources.
64
end
75
end

lib/avo/resources/resource_manager.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def fetch_resources
4141
end
4242

4343
# All descendants from Avo::Resources::Base except the internal abstract ones
44-
4544
Base.descendants.reject { _1.is_abstract? }
4645
end
4746

@@ -59,6 +58,11 @@ def load_configured_resources
5958
end
6059

6160
def initialize
61+
# Mark the BaseResource as abstract so it doesn't get loaded by the resource manager
62+
# This is made here instead of in the BaseResource class because this class can be overridden
63+
# And we don't want to force the developer that overrides this class to add the abstract resource flag to the overridden class.
64+
Avo::BaseResource.abstract_resource!
65+
6266
@resources = self.class.fetch_resources
6367
end
6468

0 commit comments

Comments
 (0)