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
Written by Dinesh Vasudevan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#