== method_finalizer

by Wilfrido T. Nuqui Jr.
[email protected]
[email protected]

== DESCRIPTION:

'method_finalizer' is a gem that allows you to declare final class and instance methods in your ruby program.

== FEATURES:

can declare
final class method(s), or
final instance method(s),
implement it and feel safe they will not be redefined

== SYNOPSIS:

Require 'rubygems' and 'method_finalizer' gems.

require 'rubygems'
require 'method_finalizer'

class A
# declare your final class and instance methods
final_class_method :method_one
final_instance_methods :method_two, :method_three

def A.method_one
"'method_one' class method in A declared as final"
end

def method_two
"'method_two' instance method in A declared as final"
end

def method_three
"'method_three' instance method in A declared as final"
end
end

Now,

class B < A
# attempting to redeclare 'method_one' as final class method
final_class_method :method_one
end

will yield this error

FinalClassMethodRedeclarationError: cannot declare 'method_one' as final method in child B as parent A declared it already as such

and when,

class B < A
# attempting to redefine 'method_one'
def self.method_one
"'method_one' class method in B"
end
end

will give you

FinalClassMethodRedefinitionError: cannot redefine 'method_one' because it is already defined as final class method in parent A.


== REQUIREMENTS:

* rake
* rubyforge
* rubygems

== INSTALL:

* sudo gem install method_finalizer

== LICENSE:

(The MIT License)

Copyright (c) 2009 Wilfrido T. Nuqui Jr.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.