include

Macro implementation of `include` keyword

include

Includes constants, classes, methods and submodules from a module into the current scope.

module TestModule
  CONSTANT = 1

  class TClass
  end
end

include_module(TestModule)

TClass    # => TestModule::TClass
CONSTANT  # => TestModule::CONSTANT

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      include:
        github: tkshnwesper/include
    
  2. Run shards install

Usage

require "include"

module TestModule
  extend self

  def test_function
  end

  CONSTANT = 1

  class TClass
  end

  module SubModule
  end
end

include_module(TestModule)

test_function   # => TestModule.test_function
SubModule       # => TestModule::SubModule

Including methods

You can only include methods if the module extends itself. See this for more details.

Contributing

  1. Fork it (https://github.com/tkshnwesper/include/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

include

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • over 2 years ago
  • April 10, 2022
License

MIT License

Links
Synced at

Wed, 06 Nov 2024 22:47:42 GMT

Languages