README in up_the_irons-immutable-0.1 vs README in up_the_irons-immutable-0.2

- old
+ new

@@ -12,11 +12,11 @@ Child classes, however, can still override the method. So this is not like Java's "final" method modifier. One can argue that in OOP, if you want to reimplement or extend a method, a -child class is the only place you should be doing that anyway. +child class is the only place where you should be doing that anyway. Alpha ----- This code is very new and despite a pretty comprehensive spec, I'm sure there's @@ -94,11 +94,10 @@ to immutable.rb and not mess with $RUBYLIB. If you installed ``Immutable`` from RubyGems, put:: require 'rubygems' - gem 'up_the_irons-immutable' require 'immutable' at the top of your programs. Using @@ -134,23 +133,53 @@ def foo :baz end end +Will raise an error: + +:: + + Cannot override the immutable method: foo (Immutable::CannotOverrideMethod) + +There is one option to immutable_method() called :silent. If :silent is true, +no exception will be raised. One can then do: + +:: + + module Foo + include Immutable + + def foo + :foo + end + + immutable_method :foo, :silent => true + end + + module Foo + def foo + :baz + end + end + include Foo foo # => :foo -Returns :foo, not :baz. +foo() returns :foo, not :baz. It did not allow itself to be overriden. Using +:silent can bring a great deal of confusion to other developers wondering why +their method overrides aren't working. I would consider using :silent bad +practice in all but very limited cases. Use with extreme caution. There is an alias for immutable_method() called immutable_methods() (plural). Use whichever style you prefer. To Do ----- -* Add option to raise exception if code tries to modify an immutable method. +I finished my TODOs, cool. Author ------ Garry C. Dolley @@ -175,19 +204,18 @@ Copyright --------- Copyright (c) 2008 Garry C. Dolley -eBay4R is free software; you can redistribute it and/or modify it under the +Immutable is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -eBay4R is distributed in the hope that it will be useful, but WITHOUT ANY +Immutable is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -eBay4R; if not, write to the Free Software Foundation, Inc., 51 Franklin +Immutable; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -