From 1ba6df104eeb876bb170cb9001de6dcc6de2dd38 Mon Sep 17 00:00:00 2001 From: Ilya Bazylchuk Date: Fri, 6 Dec 2024 13:37:52 +0100 Subject: [PATCH] Add enum set value as Symbol too --- lib/rbs_rails/active_record.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rbs_rails/active_record.rb b/lib/rbs_rails/active_record.rb index 73228de..fae0955 100644 --- a/lib/rbs_rails/active_record.rb +++ b/lib/rbs_rails/active_record.rb @@ -563,7 +563,7 @@ def authenticate_#{attribute}: (String) -> (#{klass_name} | false) mod_sig = +"module GeneratedAttributeMethods\n" mod_sig << klass.columns.map do |col| class_name = if enum_definitions.any? { |hash| hash.key?(col.name) || hash.key?(col.name.to_sym) } - '::String' + '(::String | ::Symbol)' else sql_type_to_class(col.type) end @@ -572,6 +572,7 @@ def authenticate_#{attribute}: (String) -> (#{klass_name} | false) class_name_opt = optional(class_name) column_type = col.null && !col.type.in?([:jsonb, :json]) ? class_name_opt : class_name + sig = <<~EOS def #{col.name}: () -> #{column_type} def #{col.name}=: (#{column_type}) -> #{column_type}