Skip to content

Commit

Permalink
Rename Config to ApplicationConfig
Browse files Browse the repository at this point in the history
We're now at the stage where everything on this object lives on Rails.application.config.view_component.
  • Loading branch information
boardfish committed Feb 18, 2025
1 parent 4587735 commit b159d1e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace :docs do

instance_methods_to_document = meths.select { |method| method.scope != :class }
class_methods_to_document = meths.select { |method| method.scope == :class }
configuration_methods_to_document = registry.get("ViewComponent::Config").meths.select(&:reader?)
configuration_methods_to_document = registry.get("ViewComponent::ApplicationConfig").meths.select(&:reader?)
test_helper_methods_to_document = registry
.get("ViewComponent::TestHelpers")
.meths
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
module ViewComponent
extend ActiveSupport::Autoload

autoload :ApplicationConfig
autoload :Base
autoload :CaptureCompatibility
autoload :Compiler
autoload :CompileCache
autoload :ComponentError
autoload :Config
autoload :Deprecation
autoload :InlineTemplate
autoload :Instrumentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "view_component/deprecation"

module ViewComponent
class Config
class ApplicationConfig
class << self
# `new` without any arguments initializes the default configuration, but
# it's important to differentiate in case that's no longer the case in
Expand All @@ -29,7 +29,7 @@ def defaults
controller: "ViewComponentsController",
route: "/rails/view_components",
show_source: (Rails.env.development? || Rails.env.test?),
paths: ViewComponent::Config.default_preview_paths,
paths: default_preview_paths,
default_layout: nil
],
instrumentation_enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require "action_view"
require "active_support/configurable"
require "view_component/application_config"
require "view_component/collection"
require "view_component/compile_cache"
require "view_component/compiler"
require "view_component/config"
require "view_component/errors"
require "view_component/inline_template"
require "view_component/preview"
Expand Down
4 changes: 2 additions & 2 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require "rails"
require "view_component/config"
require "view_component/application_config"
require "view_component/deprecation"

module ViewComponent
class Engine < Rails::Engine # :nodoc:
config.view_component = ViewComponent::Config.default
config.view_component = ViewComponent::ApplicationConfig.default

if Rails.version.to_f < 8.0
rake_tasks do
Expand Down
8 changes: 4 additions & 4 deletions test/sandbox/test/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module ViewComponent
class ConfigTest < TestCase
def setup
@config = ViewComponent::Config.new
@config = ViewComponent::ApplicationConfig.new
end

def test_defaults_are_correct
Expand Down Expand Up @@ -39,9 +39,9 @@ def test_all_methods_are_documented
Rake::Task["yard"].execute
configuration_methods_to_document = YARD::RegistryStore.new.tap do |store|
store.load!(".yardoc")
end.get("ViewComponent::Config").meths.select(&:reader?).reject { |meth| meth.name == :config }
default_options = ViewComponent::Config.defaults.keys
accessors = ViewComponent::Config.instance_methods(false).reject do |method_name|
end.get("ViewComponent::ApplicationConfig").meths.select(&:reader?).reject { |meth| meth.name == :config }
default_options = ViewComponent::ApplicationConfig.defaults.keys
accessors = ViewComponent::ApplicationConfig.instance_methods(false).reject do |method_name|
method_name.to_s.end_with?("=") || method_name == :method_missing
end
options_defined_on_instance = Set[*default_options, *accessors]
Expand Down

0 comments on commit b159d1e

Please sign in to comment.