File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ def execute(request, params)
82
82
sig { params ( model_name : String ) . returns ( T ::Hash [ Symbol , T . untyped ] ) }
83
83
def resolve_database_info_from_model ( model_name )
84
84
const = ActiveSupport ::Inflector . safe_constantize ( model_name )
85
- unless const && defined? ( ActiveRecord ) && const < ActiveRecord :: Base && ! const . abstract_class?
85
+ unless active_record_model? ( const )
86
86
return {
87
87
result : nil ,
88
88
}
@@ -104,6 +104,17 @@ def resolve_database_info_from_model(model_name)
104
104
rescue => e
105
105
{ error : e . full_message ( highlight : false ) }
106
106
end
107
+
108
+ sig { params ( const : T . untyped ) . returns ( T ::Boolean ) }
109
+ def active_record_model? ( const )
110
+ !!(
111
+ const &&
112
+ defined? ( ActiveRecord ) &&
113
+ const . respond_to? ( :< ) &&
114
+ const < ActiveRecord ::Base &&
115
+ !const . abstract_class?
116
+ )
117
+ end
107
118
end
108
119
end
109
120
end
You can’t perform that action at this time.
0 commit comments