Method: Contracts::Base#method_name
- Defined in:
- lib/contracts.rb
#method_name ⇒ Object
Returns a description of the method; i.e. Class#name or Class.name
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/contracts.rb', line 158 def method_name if method.is_a?(Method) # A singleton method? # The method owner is the singleton class of the class. Sadly, the # the singleton class has no name; hence we try to construct the name # from its to_s description. klass_name = method.owner.to_s.gsub(/#<(.*?):(.*)>/, "\\2") "#{klass_name}.#{method.name}" else "#{method.owner}##{method.name}" end end |