This is an update to my previous article: Making methods immutable in Ruby.
By popular demand, I’ve made my Immutable module raise an exception, by default, if you try to override an immutable method.
So, the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
require 'rubygems' require 'immutable' module Foo include Immutable def foo :foo end immutable_method :foo end module Foo def foo :baz end end |
Will raise an error:
Cannot override the immutable method: foo (Immutable::CannotOverrideMethod) |

I, for one, welcome our new immutable overlords.
Personally, I think this option of immutability is necessary for Ruby, along with the option of static typing.
Monkey patching and dynamic typing are both cool, except when they aren’t. :-)
Great job!