Reputation: 2891
I need to find which method called "abc", based on that I can do some operations.
Class A
def method1
abc
end
def method2
abc
end
def abc
puts "abc" if calling_method == :method1
puts "xyz"
end
end
Is this possible in ruby?
Upvotes: 0
Views: 811
Reputation: 5479
You can use the caller()
method.
http://www.ruby-doc.org/core-2.0/Kernel.html#method-i-caller
Upvotes: 4