Skip to content

Commit 8e1adad

Browse files
authored
Merge branch 'main' into dependabot/bundler/better_html-2.2.0
2 parents 66db001 + 8a131b6 commit 8e1adad

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ nav_order: 6
1010

1111
## main
1212

13+
* Resolve deprecation warning for `ActiveSupport::Configurable`.
14+
15+
*Simon Fish*
16+
1317
* Make `ViewComponent::VERSION` accessible to other gems by default.
1418

1519
*Hans Lemuet*

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)