Last Updated: February 25, 2016
·
330
· dinks

Module Function

Differences

module MM
  def test
    puts "test"
  end
end

class CC
  def call_test
    test
  end
end

MM.test #=> NoMethodError
CC.new.call_test #=> prints test
CC.new.test #=> prints test

This is a continuation using module_function

module MM
  module_function :test
end

MM.test #=> prints test
CC.new.call_test #=> prints test
CC.new.test #=> NoMethodError private method accessed