You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ARHP has been overriding `#class` so that `connection.class.class_eval`
can work. That makes it _very_ hard to debug ARHP issues because you're
never quite sure what object you're working with.
I've changed it so that we now raise an exception if you try to call
`.class_eval` on the `ConnectionProxy` class but implements a
`._class_eval` method that will allow the typical `class_eval` behavior
if someone _really_ needs to.
Copy file name to clipboardExpand all lines: lib/active_record_host_pool/connection_proxy.rb
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,16 @@
6
6
# for each call to the connection. upon executing a statement, the connection will switch to that database.
7
7
moduleActiveRecordHostPool
8
8
classConnectionProxy < Delegator
9
+
class << self
10
+
defclass_eval
11
+
raise"You probably want to call .class_eval on the ActiveRecord connection adapter and not on ActiveRecordHostPool's connection proxy. Use ._class_eval if you _really_ know what you're doing."
12
+
end
13
+
14
+
def_class_eval(...)
15
+
method(:class_eval).super_method.call(...)
16
+
end
17
+
end
18
+
9
19
attr_reader:database
10
20
definitialize(cx,database)
11
21
super(cx)
@@ -26,11 +36,6 @@ def unproxied
26
36
@cx
27
37
end
28
38
29
-
# this is bad. I know. but it allows folks who class_eval on connection.class to do so
0 commit comments