Module: Pinmark::SourceLocator

Defined in:
lib/pinmark/source_locator.rb

Class Method Summary collapse

Class Method Details

.for(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/pinmark/source_locator.rb', line 7

def for(klass)
  return nil unless klass.name

  file, line = Module.const_source_location(klass.name)
  return nil unless file

  relative = Pathname.new(file).relative_path_from(Rails.root)
  "#{relative}:#{line}"
end