class Skiptrace::BindingLocations
Public Class Methods
new(locations, bindings)
click to toggle source
# File lib/skiptrace/binding_locations.rb, line 3 def initialize(locations, bindings) @locations = locations @bindings = bindings @cached_locations = {} end
Private Instance Methods
cached_location(location)
click to toggle source
# File lib/skiptrace/binding_locations.rb, line 11 def cached_location(location) @cached_locations[location.to_s] ||= Location.new(location, guess_binding_around(location)) end
guess_binding_around(location)
click to toggle source
# File lib/skiptrace/binding_locations.rb, line 15 def guess_binding_around(location) location && @bindings.find do |binding| binding.source_location == [location.path, location.lineno] end end
method_missing(name, *args, &block)
click to toggle source
# File lib/skiptrace/binding_locations.rb, line 21 def method_missing(name, *args, &block) case maybe_location = @locations.public_send(name, *args, &block) when ::Thread::Backtrace::Location cached_location(maybe_location) else maybe_location end end
respond_to_missing?(name, include_all = false)
click to toggle source
# File lib/skiptrace/binding_locations.rb, line 30 def respond_to_missing?(name, include_all = false) @locations.respond_to?(name, include_all) end