Follow-up from "Implement WikiFindPage RPC"
The following discussion from !419 (merged) should be addressed:
-
@zj started a discussion: (+1 comment) Going through the source, it seems this is a common pattern. I wonder if we should create a DSL, or meta programming magic trick so we can't forget?
What we could do:
include ExceptionBridgable bridge_exceptions :wiki_find_page, :some_other_method # Under the hood we'd dynamically create a module which we'd prepend doing something like @bridgables.each do |meth| self.prepend do Module.new do define_method do |*args| bridge_exceptions do super(args) end end end end end
Or something like:
@bridgeables = self.instance_methods - self.ancestors.map { |a| a.instance_methods }.flatten.uniq # module prepending here
What do you think about this approach?
P.S. This is a comment I'm totally fine with not fixing here, but solving in an issue.
/cc @ahmadsherif