inheritance-helper
A Ruby library that provides utility methods for handling class-level inheritance in Ruby. This gem makes it easy to manage and extend class methods and their values across your inheritance chain.
Installation
Add this line to your application's Gemfile:
gem 'inheritance-helper'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install inheritance-helper
Usage
The inheritance-helper
gem provides utilities for managing class-level attributes and methods across inheritance chains. It's particularly useful when you need to accumulate or modify class-level data through inheritance.
Basic Example
class Model
extend InheritanceHelper::Methods
def self.attributes
{}.freeze
end
def self.attribute(name, type)
add_value_to_class_method(:attributes, name => type)
attr_accessor name
end
end
class Person < Model
attribute :name, :string
attribute :phone, :string
end
Person.attributes
# => {:name=>:string, :phone=>:string}
Features
- Safely extend and modify class methods through inheritance
- Preserve class-level data integrity across the inheritance chain
- Simple and intuitive API for managing class attributes
- Thread-safe implementation
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Author
Doug Youch (dougyouch+github@gmail.com)