I have a module in a file called my_mod.rb
declared like this:
module Reports
module MyMod
def mymethod
...
end
end
end
I just want to run mymethod
. It's not a class method obviously, so I can't run it like:
Reports::MyMod.mymethod
and yet I was hoping there was some way to get the method evaluated by the parser without have to go through a bunch of module_eval and module_function stuff. It should be easier than that, shouldn't it?
To run it from the rails console you just have to include it:
> include Reports::MyMod
> mymethod
class A
include Reports::MyMod
end
A.new.mymethod
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.