Skip to content

Commit

Permalink
Add enum set value as Symbol too
Browse files Browse the repository at this point in the history
  • Loading branch information
IBazylchuk committed Dec 6, 2024
1 parent 240074e commit 1ba6df1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rbs_rails/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down

0 comments on commit 1ba6df1

Please sign in to comment.