Skip to content

Commit f29041d

Browse files
authored
Merge pull request #590 from benilovj/rails-8-1
Add support for Rails 8.1
2 parents 4df4225 + 426065b commit f29041d

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
ruby: ['3.2.6', '3.3.6', '3.4.1']
14-
rails: ['7.1.5', '7.2.2', '8.0.1']
14+
rails: ['7.1.5', '7.2.2', '8.0.1', '8.1.0']
1515
runs-on: ubuntu-latest
1616
name: Testing with Ruby ${{ matrix.ruby }} and Rails ${{ matrix.rails }}
1717
steps:

lib/govuk_design_system_formbuilder.rb

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
require 'active_support/configurable'
1+
require 'active_support/ordered_options'
22
require 'html_attributes_utils'
33

44
[%w(presenters *.rb), %w(refinements *.rb), %w(traits *.rb), %w(*.rb), %w(elements ** *.rb), %w(containers ** *.rb)]
55
.flat_map { |matcher| Dir.glob(File.join(__dir__, 'govuk_design_system_formbuilder', *matcher)) }
66
.each { |file| require file }
77

88
module GOVUKDesignSystemFormBuilder
9-
include ActiveSupport::Configurable
9+
class << self
10+
class_attribute :config,
11+
instance_predicate: false,
12+
default: ActiveSupport::OrderedOptions.new
13+
14+
def inherited(klass) # :nodoc:
15+
klass.config = ActiveSupport::InheritableOptions.new(config)
16+
super
17+
end
18+
end
1019

1120
# @!group Defaults
1221

@@ -133,7 +142,20 @@ module GOVUKDesignSystemFormBuilder
133142
enable_nested_localisation: true,
134143
}.freeze
135144

136-
DEFAULTS.each_key { |k| config_accessor(k) { DEFAULTS[k] } }
145+
DEFAULTS.each do |key, value|
146+
reader = "def #{key}; config.#{key}; end"
147+
reader_line = __LINE__
148+
writer = "def #{key}=(value); config.#{key} = value; end"
149+
writer_line = __LINE__
150+
151+
singleton_class.class_eval reader, __FILE__, reader_line
152+
singleton_class.class_eval writer, __FILE__, writer_line
153+
154+
class_eval reader, __FILE__, reader_line
155+
class_eval writer, __FILE__, writer_line
156+
157+
send("#{key}=", value)
158+
end
137159
# @!endgroup
138160

139161
class << self
@@ -146,7 +168,7 @@ class << self
146168
# conf.default_error_summary_title = 'OMG'
147169
# end
148170
def configure
149-
yield(config)
171+
yield config
150172
end
151173

152174
# Resets each of the configurable values to its default

0 commit comments

Comments
 (0)