You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 19, 2018. It is now read-only.
Generate and inherit from ApplicationComponent #227
Similar to Rails by default generating an ApplicationModel < ActiveRecord::Base class which all AR generated classes inherit from User < ApplicationModel; we should generate an ApplicationComponent class and the component generator should generate components inheriting from that. E.g.
I just checked through my 12 different component classes I have in my hyperloop app, and I don't see any common code that could be promoted to a base class like ApplicationComponent. Could you give some examples of how you use this feature, behavior common to many component classes?
My view is that it is a good pattern that we should document but not be too prescriptive about. It is a very solid idea though and certainly a good one.
@barriehadfield I'd usually agree with keep it simple out of the box, but as Rails generates ApplicationRecord and ApplicationController is seems better to be consistent.
@explainer A method I added within days to help with accessing routes: #228
Another use case is with metaprogramming stuff. I'll give an example with controllers.
I wanted to autogenerate tests that every "admin_" prefixed controller included an admin authorization concern. You can loop through descendants of ApplicationController. I had an admin controller extending the RailsAdmin engine that's completely separate and I didn't want to mess with, but since it inherits from RailsAdmin::ApplicationController it's ignored anyway.
Basically having a common namespace you own that's different from what engines use helps with metaprogramming, otherwise everyone inherits from the same Hyperloop::Component and it's harder to differentiate.
It's easy enough to do add ApplicationComponent manually so this isn't an essential feature unless we deem it a beneficial default.
Activity
janbiedermann commentedon Nov 15, 2017
Thats one of the first things i did, create an ApplicationComponent. It seems very natural.
explainer commentedon Nov 16, 2017
I just checked through my 12 different component classes I have in my hyperloop app, and I don't see any common code that could be promoted to a base class like ApplicationComponent. Could you give some examples of how you use this feature, behavior common to many component classes?
barriehadfield commentedon Nov 16, 2017
My view is that it is a good pattern that we should document but not be too prescriptive about. It is a very solid idea though and certainly a good one.
sfcgeorge commentedon Nov 16, 2017
@barriehadfield I'd usually agree with keep it simple out of the box, but as Rails generates ApplicationRecord and ApplicationController is seems better to be consistent.
@explainer A method I added within days to help with accessing routes: #228
sfcgeorge commentedon Nov 16, 2017
Another use case is with metaprogramming stuff. I'll give an example with controllers.
I wanted to autogenerate tests that every "admin_" prefixed controller included an admin authorization concern. You can loop through descendants of ApplicationController. I had an admin controller extending the RailsAdmin engine that's completely separate and I didn't want to mess with, but since it inherits from RailsAdmin::ApplicationController it's ignored anyway.
Basically having a common namespace you own that's different from what engines use helps with metaprogramming, otherwise everyone inherits from the same Hyperloop::Component and it's harder to differentiate.
It's easy enough to do add ApplicationComponent manually so this isn't an essential feature unless we deem it a beneficial default.