Skip to content

Fix Ruby 3 constant lookup error #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rails-settings-ui/settings_form_coercible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ class SettingsFormCoercible
attr_reader :settings, :default_settings
attr_accessor :coerced_settings

integer_klass = defined?(Fixnum) ? Fixnum : Integer
COERCIONS_MAP = {
String => Types::Coercible::String,
Symbol => Types::CustomCoercions::Symbol,
(1.class == Integer ? Integer : Fixnum) => Types::Params::Integer,
integer_klass => Types::Params::Integer,
ActiveSupport::HashWithIndifferentAccess => Types::CustomCoercions::Hash,
ActiveSupport::Duration => Types::Params::Integer,
Float => Types::Params::Float,
Expand Down
3 changes: 2 additions & 1 deletion lib/rails-settings-ui/settings_form_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class SettingsSchema < Dry::Validation::Schema::Params
end

class SettingsFormValidator
integer_klass = defined?(Fixnum) ? Fixnum : Integer
VALIDATABLE_TYPES = {
(1.class == Integer ? Integer : Fixnum) => :int?,
integer_klass => :int?,
Float => :float?,
ActiveSupport::Duration => :int?,
ActiveSupport::HashWithIndifferentAccess => :form_hash?
Expand Down
3 changes: 2 additions & 1 deletion lib/rails-settings-ui/type_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ module RailsSettingsUi
class UnknownDefaultValueType < StandardError;end

class TypeConverter
integer_klass = defined?(Fixnum) ? Fixnum : Integer
VALUE_TYPES_MAP = {
String => RailsSettingsUi::ValueTypes::String,
Symbol => RailsSettingsUi::ValueTypes::Symbol,
Fixnum => RailsSettingsUi::ValueTypes::Fixnum,
integer_klass => RailsSettingsUi::ValueTypes::Fixnum,
# ActiveSupport::HashWithIndifferentAccess => RailsSettingsUi::ValueTypes::Hash,
ActiveSupport::Duration => RailsSettingsUi::ValueTypes::Float,
Float => RailsSettingsUi::ValueTypes::Float,
Expand Down
Loading