0.01
No release in over 3 years
Extendable module for modules with instance and class methods. These modules can be included into each other modules and saving all chain, including `inherited` or `included` (class) methods.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 0.1.0
~> 0.1.0
~> 3.9
~> 0.86.0
~> 0.18.0
~> 0.10.0
 Project Readme

Module Methods

Cirrus CI - Base Branch Build Status Codecov branch Code Climate Depfu Inline docs license Gem

Extendable module for modules with instance and class methods. These modules can be included into each other modules and saving all chain, including inherited or included (class) methods.

There are no conflicts with ActiveSupport::Concern.

Installation

Add this line to your application's Gemfile:

gem 'module_methods'

And then execute:

bundle install

Or install it yourself as:

gem install module_methods

Usage

require 'module_methods'

module SomeCommonCode
  extend ::ModuleMethods::Extension

  module ClassMethods
    def inherited(klass)
      ## manipulations with klass
    end
  end

  def some_method
    ## this is instance method
  end
end

module MoreSpecificCommonCode
  include SomeCommonCode

  module ClassMethods
    def inherited(klass)
      ## you can control the order of `inherited` execution by `super`
      ## this `super` executes `inherited` in `SomeCommonCode`
      super
    end
  end

  def some_another_method
    ## This is another instance method.
  end
end

class BaseClass
  include MoreSpecificCommonCode

  ## Instance methods from modules are here.
end

class EndPoint < BaseClass
  ## Both `inherited` from `SomeCommonCode` and `MoreSpecificCommonCode`
  ## are executing here; private methods from modules are also here.
end

Development

After checking out the repo, run bundle install to install dependencies.

Then, run toys rspec to run the tests.

To install this gem onto your local machine, run toys gem install.

To release a new version, run toys gem release %version%. See how it works here.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

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