Skip to content

Commit 56dc028

Browse files
committed
Resolve ActiveSupport::Configurable deprecation warnings
Similar to rails/rails#53970, replicates its functionality inside `ViewComponent::Configurable`.
1 parent 15443f3 commit 56dc028

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

lib/view_component/base.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require "action_view"
4-
require "active_support/configurable"
54
require "view_component/collection"
65
require "view_component/compile_cache"
76
require "view_component/compiler"

lib/view_component/configurable.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@ module ViewComponent
44
module Configurable
55
extend ActiveSupport::Concern
66

7+
class_methods do
8+
def config
9+
@_config ||= if respond_to?(:superclass) && superclass.respond_to?(:config)
10+
superclass.config.inheritable_copy
11+
else
12+
ActiveSupport::OrderedOptions.new
13+
end
14+
end
15+
16+
def configure
17+
yield config
18+
end
19+
end
20+
721
included do
822
next if respond_to?(:config) && config.respond_to?(:view_component) && config.respond_to_missing?(:instrumentation_enabled)
923

10-
include ActiveSupport::Configurable
11-
1224
configure do |config|
1325
config.view_component ||= ActiveSupport::InheritableOptions.new
1426
end
27+
28+
def config
29+
self.class.config
30+
end
1531
end
1632
end
1733
end

0 commit comments

Comments
 (0)