Issue
Assuming I have:
module X::Y::Z::M
def foo
end
end
How in foo can I dynamically determine the module X::Y::Z::M in the foo
method? self.class
will not work because it will evaluate to the class that includes the module.
Solution
You can use Module.nesting
method which returns an array of nesting modules, Refer nesting method of Moudle
module X::Y::Z::M
def foo
Module.nesting.first
end
end
Answered By - Supriya Medankar Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.