-
Notifications
You must be signed in to change notification settings - Fork 108
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
Move global configuration #403
Comments
Happy to discuss this in more detail, and elaborate more. |
@sandstrom Apologies for the delay here, and thanks for the detailed suggestion! I think this would be a valuable addition to the library, and leveraging |
|
Not to split hairs here, but I wouldn't consider it explicitly a Rails implementation; this functionality was extracted from If we don't want to bring in an intentional dependency on |
I don't have a strong preference. Should be fairly easy to replicate the logic of Breaking changesWhat's your view on breaking changes and major releases? Some projects are happy about frequent major release, others prefer making them only once every year or two. I'm fine with either, but it's good to know since this change could potentially be implemented as a breaking change, but also doable in a manner where global conf is used as fallback (non-breaking scenario). |
This is a major refactor and I would personally prefer combining this with any/some other major deprecations planned for the near future as a potential 2.x release. Maybe this could go into a separate 2.x branch. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still relevant! |
I think I'm on board with this. "Global" config could go into an I'd vote against using ActiveSupport for |
@jhollinger Do you know of a blog post or similar explaining how to replicate Or are you simply thinking of something like this: class Mother
@things = []
class << self
attr_accessor :things
end
def self.inherited(subclass)
puts "New subclass: #{subclass}"
subclass.things = self.things.dup
end
end
class Child < Mother
end |
@sandstrom Yes, assuming we only have a handful of attributes to keep track of, the above is what I was thinking. |
Hi guys, Hope I'm on the right topic. Should this mean that after this feature is implemented, it will be possible to have two separate I'm trying to work around an issue with setting this configs, that impacts the views and associations in another Blueprint. Here the fix I found that works for me:
|
Yes, that would be possible |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale |
FYI, this is now part of a proposed V2 base class in #437 (along with other changes). All configuration, and fields, are held in Blueprint classes and are inheritable. To simulate "global" config in V2, options and default fields can be configured in an |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe
If blueprinter is used for different things in a single codebase, the global configuration cannot be used.
For example, one might have two APIs (public and internal), and want to use blueprinter for both, but with different configuration for each.
Describe the feature you'd like to see implemented
Deprecate global configuration and move configuration to the base class.
Make it possible to override in subclasses, thereby relying on the common class inheritance pattern to handle "global configuration".
As for making sure configs are not shared (only copied) down the inheritance hiearchy, I'd probably pull in
class_attribute
from ActiveSupport (https://guides.rubyonrails.org/active_support_core_extensions.html#class-attributes).If you want to add it manually there is some inspiration here:
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: