module Core end
module Core::BaseService
extend self
def bar
puts 'bar'
end
end
require_relative './base_service.rb'
module Core::Payments
module Service
extend self, Core::BaseService
def fuu
puts 'fuuu'
end
end
end
Core::Payments::Service.bar # => 'bar'
Core::Payments::Service.fuu # => 'fuuu'
lib
|
|---core
|
|---base_service.rb
|---payments
|
|---service.rb
|---confing_or_something.rb
module_function
makes the given instance methods private, then duplicates and
puts them into the module's metaclass as public methods.
extend self
adds all instance methods to the module's singleton, leaving their visibilities unchanged.
module Mathematics
extend self
def calc
42
end
end
module Mathematics
module_function
def calc
42
end
end
See more: https://idiosyncratic-ruby.com/8-self-improvement.html