ruby - Call module method from other class -
so have 1 ruby file reside inside model > service
module services module somejobs def mainjob ... end end end
and how call method ruby class sit inside lib/testfunction.rb
i tried following , did not work. appreciate. trying debug code.
class testfunction include somejobs testfunction::mainjob end
try out
module services module somejobs def self.mainjob end end end
make mainjob module method, module instance method never included in including class, private module
class testfunction include services::somejobs end
now call from
outside testfunction class like
testfunction.new.mainjob
and inside testfunction class with
self.class.new.mainjob
if want access mainjob class method then, use extend instead of include.
as using ide debugger
try requiring file relative rails application, in
testfunction class
Comments
Post a Comment