-
Notifications
You must be signed in to change notification settings - Fork 429
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
Initialize ViewComponent::Config with defaults before framework load #1774
Changes from all commits
0dd2cf9
1b1ebc4
a3ed95f
fdceb20
0cd09a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,14 @@ def default_generate_options | |
end | ||
end | ||
|
||
# @!attribute current | ||
# @return [ViewComponent::Config] | ||
# Returns the current ViewComponent::Config. This is persisted against this | ||
# class so that config options remain accessible before the rest of | ||
# ViewComponent has loaded. Defaults to an instance of ViewComponent::Config | ||
# with all other documented defaults set. | ||
class_attribute :current, default: defaults, instance_predicate: false | ||
Comment on lines
+170
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, we need to regenerate the YARD docs to include this. |
||
|
||
def initialize | ||
@config = self.class.defaults | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
module ViewComponent # :nodoc: | ||
class Preview | ||
include Rails.application.routes.url_helpers if defined?(Rails.application.routes.url_helpers) | ||
include Rails.application.routes.url_helpers if defined?(Rails) && Rails.application.present? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think #1774 (review) was resolved correctly - I think ultimately this change can be reverted. Originally @boardfish had committed diff --git a/lib/view_component/preview.rb b/lib/view_component/preview.rb
index e80087404..3176e4ecd 100644
--- a/lib/view_component/preview.rb
+++ b/lib/view_component/preview.rb
@@ -4,7 +4,7 @@
module ViewComponent # :nodoc:
class Preview
- include Rails.application.routes.url_helpers
+ include Rails.application.routes.url_helpers if Rails && Rails.application.present?
include ActionView::Helpers::TagHelper
include ActionView::Helpers::AssetTagHelper
extend ActiveSupport::DescendantsTracker in e4268dc before 0d6564a had landed in Technically, it's possible (though admittedly weird) to have an environment where |
||
include ActionView::Helpers::TagHelper | ||
include ActionView::Helpers::AssetTagHelper | ||
extend ActiveSupport::DescendantsTracker | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to regenerate the YARD docs after removing this.