File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,19 @@ module Rails
55 # When this is included in a Rails app, check if `Components::Base` is defined and
66 # inherit from that so we get all the users stuff; otherwise inherit from Phlex::HTML,
77 # which means we won't have all the users methods and overrides.
8- Component = defined? ( ::Components ::Base ) ? ::Components ::Base : ::Phlex ::HTML
8+ SUPERCLASSES = [
9+ "::Components::Base" , # Phlex 2.x base class in a Rails project
10+ "::ApplicationComponent" , # Phlex 1.x base class in a Rails project
11+ "::Phlex::HTML" , # Couldn't detect a base Phlex Rails class, so use Phlex::HTML
12+ ]
13+
14+ # Find the base class for the Rails app.
15+ def self . base_class
16+ const_get SUPERCLASSES . find { |const | const_defined? ( const ) }
17+ end
18+
19+ # Set the base class for the remainder of this library.
20+ Component = base_class
921
1022 # A Phlex::HTML view module that accepts a model and sets a `Superform::Namespace`
1123 # with the `Object#model_name` as the key and maps the object to form fields
You can’t perform that action at this time.
0 commit comments