Skip to content

Commit f71b74e

Browse files
committed
Fix compatibility with Ruby 3
1 parent 0c35c1b commit f71b74e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/rails-settings-ui/settings_form_coercible.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ class SettingsFormCoercible
4242
attr_reader :settings, :default_settings
4343
attr_accessor :coerced_settings
4444

45+
integer_klass = defined?(Fixnum) ? Fixnum : Integer
4546
COERCIONS_MAP = {
4647
String => Types::Coercible::String,
4748
Symbol => Types::CustomCoercions::Symbol,
48-
(1.class == Integer ? Integer : Fixnum) => Types::Params::Integer,
49+
integer_klass => Types::Params::Integer,
4950
ActiveSupport::HashWithIndifferentAccess => Types::CustomCoercions::Hash,
5051
ActiveSupport::Duration => Types::Params::Integer,
5152
Float => Types::Params::Float,

lib/rails-settings-ui/settings_form_validator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class SettingsSchema < Dry::Validation::Schema::Params
1919
end
2020

2121
class SettingsFormValidator
22+
integer_klass = defined?(Fixnum) ? Fixnum : Integer
2223
VALIDATABLE_TYPES = {
23-
(1.class == Integer ? Integer : Fixnum) => :int?,
24+
integer_klass => :int?,
2425
Float => :float?,
2526
ActiveSupport::Duration => :int?,
2627
ActiveSupport::HashWithIndifferentAccess => :form_hash?

lib/rails-settings-ui/type_converter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ module RailsSettingsUi
1111
class UnknownDefaultValueType < StandardError;end
1212

1313
class TypeConverter
14+
integer_klass = defined?(Fixnum) ? Fixnum : Integer
1415
VALUE_TYPES_MAP = {
1516
String => RailsSettingsUi::ValueTypes::String,
1617
Symbol => RailsSettingsUi::ValueTypes::Symbol,
17-
Fixnum => RailsSettingsUi::ValueTypes::Fixnum,
18+
integer_klass => RailsSettingsUi::ValueTypes::Fixnum,
1819
# ActiveSupport::HashWithIndifferentAccess => RailsSettingsUi::ValueTypes::Hash,
1920
ActiveSupport::Duration => RailsSettingsUi::ValueTypes::Float,
2021
Float => RailsSettingsUi::ValueTypes::Float,

0 commit comments

Comments
 (0)