Skip to content

Commit b159d1e

Browse files
committed
Rename Config to ApplicationConfig
We're now at the stage where everything on this object lives on Rails.application.config.view_component.
1 parent 4587735 commit b159d1e

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace :docs do
8282

8383
instance_methods_to_document = meths.select { |method| method.scope != :class }
8484
class_methods_to_document = meths.select { |method| method.scope == :class }
85-
configuration_methods_to_document = registry.get("ViewComponent::Config").meths.select(&:reader?)
85+
configuration_methods_to_document = registry.get("ViewComponent::ApplicationConfig").meths.select(&:reader?)
8686
test_helper_methods_to_document = registry
8787
.get("ViewComponent::TestHelpers")
8888
.meths

lib/view_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
module ViewComponent
77
extend ActiveSupport::Autoload
88

9+
autoload :ApplicationConfig
910
autoload :Base
1011
autoload :CaptureCompatibility
1112
autoload :Compiler
1213
autoload :CompileCache
1314
autoload :ComponentError
14-
autoload :Config
1515
autoload :Deprecation
1616
autoload :InlineTemplate
1717
autoload :Instrumentation
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "view_component/deprecation"
44

55
module ViewComponent
6-
class Config
6+
class ApplicationConfig
77
class << self
88
# `new` without any arguments initializes the default configuration, but
99
# it's important to differentiate in case that's no longer the case in
@@ -29,7 +29,7 @@ def defaults
2929
controller: "ViewComponentsController",
3030
route: "/rails/view_components",
3131
show_source: (Rails.env.development? || Rails.env.test?),
32-
paths: ViewComponent::Config.default_preview_paths,
32+
paths: default_preview_paths,
3333
default_layout: nil
3434
],
3535
instrumentation_enabled: false,

lib/view_component/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
require "action_view"
44
require "active_support/configurable"
5+
require "view_component/application_config"
56
require "view_component/collection"
67
require "view_component/compile_cache"
78
require "view_component/compiler"
8-
require "view_component/config"
99
require "view_component/errors"
1010
require "view_component/inline_template"
1111
require "view_component/preview"

lib/view_component/engine.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

33
require "rails"
4-
require "view_component/config"
4+
require "view_component/application_config"
55
require "view_component/deprecation"
66

77
module ViewComponent
88
class Engine < Rails::Engine # :nodoc:
9-
config.view_component = ViewComponent::Config.default
9+
config.view_component = ViewComponent::ApplicationConfig.default
1010

1111
if Rails.version.to_f < 8.0
1212
rake_tasks do

test/sandbox/test/config_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module ViewComponent
66
class ConfigTest < TestCase
77
def setup
8-
@config = ViewComponent::Config.new
8+
@config = ViewComponent::ApplicationConfig.new
99
end
1010

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

0 commit comments

Comments
 (0)