Method: MethodSource::MethodExtensions#source

Defined in:
lib/method_source.rb

#sourceString

Return the sourcecode for the method as a string

Examples:

Set.instance_method(:clear).source.display
=>
   def clear
     @hash.clear
     self
   end

Returns:

  • (String)

    The method sourcecode as a string

Raises:

  • SourceNotFoundException



114
115
116
# File 'lib/method_source.rb', line 114

def source
  MethodSource.source_helper(source_location, defined?(name) ? name : inspect)
end