How does this ruby error handling module code work
- by Michael Durrant
Trying to get a better handle on ruby exception handling.
I have this code (from a book):
def err_with_msg(pattern)
m = Module.new
(class << m; self; end).instance_eval do
define_method(:===) do |e|
pattern === e.msg
end
end
m
end
So ok this is a method.
We're creating a new Module. I think of module as mix-ins. Not…