0.0
No commit activity in last 3 years
No release in over 3 years
This gem makes the specified method non-overridable in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 3.8.0
~> 10.0
~> 3.0
~> 0.80.0
 Project Readme

Build Status Gem Version

Finalizable

This gem makes the specified method non-overridable in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'finalizable'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install finalizable

Usage

see lib/finalizable/example/

Example of parent class which is using final and somewhat_final.

class ParentClass
  include ::Finalizable
  final :final_method_defined_in_parent_class
  somewhat_final :somewhat_final_method_defined_in_parent_class

  def final_method_defined_in_parent_class
    :return_value_from_parent_class
  end

  def somewhat_final_method_defined_in_parent_class
    :return_value_from_parent_class
  end

  def overridable_method_defined_in_parent_class
    :return_value_from_parent_class
  end
end
  • If subclass overrides the method final_method_defined_in_parent_class, you will get Finalizable::OverrideError on loading time not runtime.
  • If subclass overrides the method somewhat_final_method_defined_in_parent_class, you will get a Kernel#.warn message.
WARNING: Child class 'Finalizable::Example::AClassSomeMethodsAreNotAllowedOverriding' should not override parent class method 'Finalizable::Example::ParentClass.somewhat_final_method_defined_in_parent_class'.

Example

https://github.com/hgwr/finalizable_example

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/finalizable.

License

The gem is available as open source under the terms of the MIT License.