I guess that is because self
pointer inside of do_something input
is InternshipInputFormatter
, and not the instance of InternshipInputFormatter
. so proper alias to call helper_method(input)
will be self.helper_method(input)
, however you have included the Helper::MyHelper
into the InternshipInputFormatter
class as an instance methods, not a singleton, so try to extend the class with the instance methods of the module as the signelton methods for the class:
class InternshipInputFormatter
extend Helper::MyHelper
def self.do_something input
helper_method(input)
end
end
InternshipInputFormatter.do_something 1
# NoMethodError: undefined method `titleize' for 1:Fixnum
As you can see, the call has stopped the execution inside the helper_method
. Please refer to the document to see the detailed difference between include
, and extend
.