Skip to content
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