Skip to content

Commit a430c7f

Browse files
committed
fix: module/class lookup deprecation
1 parent 85b8460 commit a430c7f

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/java/arjdbc/ArJdbcModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private static IRubyObject loadDriver(final ThreadContext context, final IRubyOb
232232

233233
final RubyModule jdbc = runtime.getModule("Jdbc");
234234
if ( jdbc != null ) { // Jdbc::MySQL
235-
final RubyModule constant = (RubyModule) jdbc.getConstantAt(constName);
235+
final RubyModule constant = (RubyModule) jdbc.getConstant(constName);
236236
if ( constant != null ) { // ::Jdbc::MySQL.load_driver :
237237
if ( constant.respondsTo("load_driver") ) {
238238
IRubyObject result = constant.callMethod("load_driver");

src/java/arjdbc/jdbc/RubyJdbcConnection.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ public class RubyJdbcConnection extends RubyObject {
135135

136136
protected RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
137137
super(runtime, metaClass);
138-
attributeClass = runtime.getModule("ActiveModel").getClass("Attribute");
139-
timeZoneClass = runtime.getModule("ActiveSupport").getClass("TimeWithZone");
138+
attributeClass = (RubyClass) runtime.getModule("ActiveModel").getConstant("Attribute");
139+
timeZoneClass = (RubyClass) runtime.getModule("ActiveSupport").getConstant("TimeWithZone");
140140
}
141141

142142
private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
@@ -153,39 +153,39 @@ public static RubyClass createJdbcConnectionClass(final Ruby runtime) {
153153
}
154154

155155
public static RubyClass getJdbcConnection(final Ruby runtime) {
156-
return (RubyClass) getConnectionAdapters(runtime).getConstantAt("JdbcConnection");
156+
return (RubyClass) getConnectionAdapters(runtime).getConstant("JdbcConnection");
157157
}
158158

159159
protected static RubyModule ActiveRecord(ThreadContext context) {
160160
return context.runtime.getModule("ActiveRecord");
161161
}
162162

163163
public static RubyClass getBase(final Ruby runtime) {
164-
return (RubyClass) runtime.getModule("ActiveRecord").getConstantAt("Base");
164+
return (RubyClass) runtime.getModule("ActiveRecord").getConstant("Base");
165165
}
166166

167167
/**
168168
* @param runtime
169169
* @return <code>ActiveRecord::Result</code>
170170
*/
171171
public static RubyClass getResult(final Ruby runtime) {
172-
return (RubyClass) runtime.getModule("ActiveRecord").getConstantAt("Result");
172+
return (RubyClass) runtime.getModule("ActiveRecord").getConstant("Result");
173173
}
174174

175175
/**
176176
* @param runtime
177177
* @return <code>ActiveRecord::ConnectionAdapters</code>
178178
*/
179179
public static RubyModule getConnectionAdapters(final Ruby runtime) {
180-
return (RubyModule) runtime.getModule("ActiveRecord").getConstantAt("ConnectionAdapters");
180+
return (RubyModule) runtime.getModule("ActiveRecord").getConstant("ConnectionAdapters");
181181
}
182182

183183
/**
184184
* @param runtime
185185
* @return <code>ActiveRecord::ConnectionAdapters::IndexDefinition</code>
186186
*/
187187
protected static RubyClass getIndexDefinition(final Ruby runtime) {
188-
return getConnectionAdapters(runtime).getClass("IndexDefinition");
188+
return (RubyClass) getConnectionAdapters(runtime).getConstant("IndexDefinition");
189189
}
190190

191191
/**
@@ -194,31 +194,31 @@ protected static RubyClass getIndexDefinition(final Ruby runtime) {
194194
* @note only since AR 4.2
195195
*/
196196
protected static RubyClass getForeignKeyDefinition(final Ruby runtime) {
197-
return getConnectionAdapters(runtime).getClass("ForeignKeyDefinition");
197+
return (RubyClass) getConnectionAdapters(runtime).getConstant("ForeignKeyDefinition");
198198
}
199199

200200
/**
201201
* @param runtime
202202
* @return <code>ActiveRecord::JDBCError</code>
203203
*/
204204
protected static RubyClass getJDBCError(final Ruby runtime) {
205-
return runtime.getModule("ActiveRecord").getClass("JDBCError");
205+
return (RubyClass) runtime.getModule("ActiveRecord").getConstant("JDBCError");
206206
}
207207

208208
/**
209209
* @param runtime
210210
* @return <code>ActiveRecord::ConnectionNotEstablished</code>
211211
*/
212212
protected static RubyClass getConnectionNotEstablished(final Ruby runtime) {
213-
return runtime.getModule("ActiveRecord").getClass("ConnectionNotEstablished");
213+
return (RubyClass) runtime.getModule("ActiveRecord").getConstant("ConnectionNotEstablished");
214214
}
215215

216216
/**
217217
* @param runtime
218218
* @return <code>ActiveRecord::NoDatabaseError</code>
219219
*/
220220
protected static RubyClass getNoDatabaseError(final Ruby runtime) {
221-
return runtime.getModule("ActiveRecord").getClass("NoDatabaseError");
221+
return (RubyClass) runtime.getModule("ActiveRecord").getConstant("NoDatabaseError");
222222
}
223223

224224
/**
@@ -351,7 +351,7 @@ protected void setTransactionIsolation(final ThreadContext context, final Connec
351351
connection.setTransactionIsolation(level);
352352
}
353353
catch (SQLException e) {
354-
RubyClass txError = ActiveRecord(context).getClass("TransactionIsolationError");
354+
RubyClass txError = (RubyClass) ActiveRecord(context).getConstant("TransactionIsolationError");
355355
if ( txError != null ) throw wrapException(context, txError, e);
356356
throw e; // let it roll - will be wrapped into a JDBCError (non 4.0)
357357
}
@@ -485,7 +485,7 @@ protected void releaseSavepoint(final Connection connection, final Savepoint sav
485485
}
486486

487487
protected static RuntimeException newSavepointNotSetError(final ThreadContext context, final IRubyObject name, final String op) {
488-
RubyClass StatementInvalid = ActiveRecord(context).getClass("StatementInvalid");
488+
RubyClass StatementInvalid = (RubyClass) ActiveRecord(context).getConstant("StatementInvalid");
489489
return context.runtime.newRaiseException(StatementInvalid, "could not " + op + " savepoint: '" + name + "' (not set)");
490490
}
491491

@@ -1437,7 +1437,7 @@ context, caseConvertIdentifierForRails(metaData, columnName)
14371437

14381438
protected RubyClass getIndexDefinition(final ThreadContext context) {
14391439
final RubyClass adapterClass = adapter.getMetaClass();
1440-
IRubyObject IDef = adapterClass.getConstantAt("IndexDefinition");
1440+
IRubyObject IDef = adapterClass.getConstant("IndexDefinition");
14411441
return IDef != null ? (RubyClass) IDef : getIndexDefinition(context.runtime);
14421442
}
14431443

@@ -1511,7 +1511,7 @@ protected String extractForeignKeyRule(final int rule) {
15111511

15121512
protected RubyClass getForeignKeyDefinition(final ThreadContext context) {
15131513
final RubyClass adapterClass = adapter.getMetaClass();
1514-
IRubyObject FKDef = adapterClass.getConstantAt("ForeignKeyDefinition");
1514+
IRubyObject FKDef = adapterClass.getConstant("ForeignKeyDefinition");
15151515
return FKDef != null ? (RubyClass) FKDef : getForeignKeyDefinition(context.runtime);
15161516
}
15171517

0 commit comments

Comments
 (0)