Sha256: 1fa96d372de69ec59e442abf0cd15a9f558b37e12c19dcf472185e45b67bed1e

Contents?: true

Size: 605 Bytes

Versions: 90

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true
# typed: false

module T::Private::CallerUtils
  if Thread.respond_to?(:each_caller_location) # RUBY_VERSION >= "3.2"
    def self.find_caller
      skipped_first = false
      Thread.each_caller_location do |loc|
        unless skipped_first
          skipped_first = true
          next
        end

        next if loc.path&.start_with?("<internal:")

        return loc if yield(loc)
      end
      nil
    end
  else
    def self.find_caller
      caller_locations(2).find do |loc|
        !loc.path&.start_with?("<internal:") && yield(loc)
      end
    end
  end
end

Version data entries

90 entries across 90 versions & 1 rubygems

Version Path
sorbet-runtime-0.5.11670 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11668 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11663 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11647 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11645 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11642 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11641 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11637 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11635 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11633 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11631 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11630 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11625 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11620 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11618 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11615 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11611 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11610 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11609 lib/types/private/caller_utils.rb
sorbet-runtime-0.5.11608 lib/types/private/caller_utils.rb