-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert load hooks for collaborator gems #335
Conversation
This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing specific extensions and pulling them in to our repo. Note: we can skip the surrounding `billing_enabled?` checks, since we already know its enabled by the fact that we're loading the very library.
Took me a bit to figure out locally, but I got the |
This means collaborator gems, particularly the bullet_train-billing(-*) ones, can hook in and help define extra functionality. Here's how that would look: ```ruby module BulletTrain::Billing::Teams::Base extend ActiveSupport::Concern included do has_many :billing_subscriptions, class_name: "Billing::Subscription", dependent: :destroy, foreign_key: :team_id end end ActiveSupport.on_load(:bullet_train_teams_base) { include BulletTrain::Billing::Teams::Base } ``` Collaborator gems must be concerns otherwise features won't be included into the class that includes `::Teams::Base`. That's because regular Ruby modules don't support this kind of deep nesting but concerns have specifically added that. Note: this is also how Rails works internally and expects you to hook into its libraries, like Active Record.
d6a73a1
to
3522b48
Compare
Rebased out eb622ba now that master doesn't have that anymore. |
This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing-stripe specific extensions and pulling them in to our repo. Note: we can skip the surrounding `defined?(Billing::Stripe::Subscription)` checks, since we already know its enabled by the fact that we're loading the very library.
Found more places we're extending these concerns with other modules. So I put in extra load hooks and I'll do a double check on the collaborator gems again. Edit: just bullet_train-billing needed updating. |
This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing specific extensions and pulling them in to our repo. Note: we can skip the surrounding `billing_enabled?` checks, since we already know its enabled by the fact that we're loading the very library.
This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing-stripe specific extensions and pulling them in to our repo. Note: we can skip the surrounding `defined?(Billing::Stripe::Subscription)` checks, since we already know its enabled by the fact that we're loading the very library.
Note to self: don't delete the branch yet, the starter repo still relies on it. |
* Use Teams::Base load hook to insert functionality This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing specific extensions and pulling them in to our repo. Note: we can skip the surrounding `billing_enabled?` checks, since we already know its enabled by the fact that we're loading the very library. * Extract remaining Billing extensions to our repo * Add an AbilitySupport load hook for other billing libraries * Add hook to inject provider_subscription_attributes
* Use Teams::Base load hook to insert functionality This work is dependent on bullet-train-co/bullet_train-core#335 being shipped. Then we're just grabbing the bullet_train-billing-stripe specific extensions and pulling them in to our repo. Note: we can skip the surrounding `defined?(Billing::Stripe::Subscription)` checks, since we already know its enabled by the fact that we're loading the very library. * Use AbilitySupport load hook to insert functionality * Hook into BulletTrain::Billing.provider_subscription_attributes * Hide behind compatibility hook for backwardscompatibility
We inserted load hooks in #335, and then used them in bullet-train-pro/bullet_train-billing#19 We've shipped releases with that new code, so we can remove our inline backing code from here.
We inserted load hooks in #335, and then used them in bullet-train-pro/bullet_train-billing#19 We've shipped releases with that new code, so we can remove our inline backing code from here.
We inserted load hooks in #335, and then used them in bullet-train-pro/bullet_train-billing#19 We've shipped releases with that new code, so we can remove our inline backing code from here.
We inserted load hooks in #335, and then used them in bullet-train-pro/bullet_train-billing#19 We've shipped releases with that new code, so we can remove our inline backing code from here.
This means collaborator gems, particularly the bullet_train-billing(-*) ones, can hook in and help define extra functionality. Here's how that would look:
Collaborator gems must use concerns otherwise features won't be included into the class that includes
::Teams::Base
. That's because regular Ruby modules don't support this kind of deep nesting but concerns have specifically added that.Note: this is also how Rails works internally and expects you to hook into its libraries, like Active Record.
How to ship this
bullet_train-core
that removes all the billing related extensions inTeams::Base
, then merge.