Sha256: 4580354c147b27d78e372cc8d233e8db414fe4e912a5a16dbead03b65688f31a

Contents?: true

Size: 728 Bytes

Versions: 329

Compression:

Stored size: 728 Bytes

Contents

module Test
  module Unit
    module Util
      module MethodOwnerFinder
        module_function
        def find(object, method_name)
          method = object.method(method_name)
          return method.owner if method.respond_to?(:owner)

          if /\((.+?)\)\#/ =~ method.to_s
            owner_name = $1
            if /\A#</ =~ owner_name
              ObjectSpace.each_object(Module) do |mod|
                return mod if mod.to_s == owner_name
              end
            else
              owner_name.split(/::/).inject(Object) do |parent, name|
                parent.const_get(name)
              end
            end
          else
            object.class
          end
        end
      end
    end
  end
end

Version data entries

329 entries across 282 versions & 29 rubygems

Version Path
whitelabelmachinename-ruby-sdk-3.1.7 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.1.6 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.1.5 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
postfinancecheckout-ruby-sdk-3.1.4 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.1.4 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
wallee-ruby-sdk-3.1.4 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
wallee-ruby-sdk-3.1.3 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.1.3 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.1.2 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
wallee-ruby-sdk-3.1.2 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
wallee-ruby-sdk-3.1.1 vendor/bundle/ruby/2.4.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
rhodes-7.5.1 spec/framework_spec/extensions/test-libs/test/unit/util/method-owner-finder.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/test-unit-3.5.3/lib/test/unit/util/method-owner-finder.rb
whitelabelmachinename-ruby-sdk-3.0.6 vendor/bundle/ruby/2.7.0/gems/test-unit-3.2.9/lib/test/unit/util/method-owner-finder.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/test-unit-3.5.3/lib/test/unit/util/method-owner-finder.rb
ric-0.14.2 vendor/bundle/ruby/2.7.0/gems/test-unit-3.5.3/lib/test/unit/util/method-owner-finder.rb
ric-0.14.1 vendor/bundle/ruby/2.7.0/gems/test-unit-3.5.3/lib/test/unit/util/method-owner-finder.rb
ric-0.14.0 vendor/bundle/ruby/2.7.0/gems/test-unit-3.5.3/lib/test/unit/util/method-owner-finder.rb
test-unit-3.5.3 lib/test/unit/util/method-owner-finder.rb
test-unit-3.5.2 lib/test/unit/util/method-owner-finder.rb