Sha256: eadc1d016427ebd2b3ba360bbf08cec603ed64a744616cf133fbc57a73e450ab

Contents?: true

Size: 588 Bytes

Versions: 19

Compression:

Stored size: 588 Bytes

Contents

unless Method.method_defined? :super_method
  require 'backports/1.8.7/array/find_index'

  class Method
    def super_method
      singleton_klass = class << receiver; self; end
      call_chain = singleton_klass.ancestors
      # find current position in call chain:
      skip = call_chain.find_index{|c| c == owner} or return
      call_chain = call_chain.drop(skip + 1)
      # find next in chain with a definition:
      next_index = call_chain.find_index{|c| c.method_defined? name}
      next_index && call_chain[next_index].instance_method(name).bind(receiver)
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/2.2.0/method/super_method.rb
backports-3.16.1 lib/backports/2.2.0/method/super_method.rb
backports-3.16.0 lib/backports/2.2.0/method/super_method.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/backports-3.15.0/lib/backports/2.2.0/method/super_method.rb
backports-3.15.0 lib/backports/2.2.0/method/super_method.rb
backports-3.14.0 lib/backports/2.2.0/method/super_method.rb
backports-3.13.0 lib/backports/2.2.0/method/super_method.rb
backports-3.12.0 lib/backports/2.2.0/method/super_method.rb
backports-3.11.4 lib/backports/2.2.0/method/super_method.rb
backports-3.11.3 lib/backports/2.2.0/method/super_method.rb
backports-3.11.2 lib/backports/2.2.0/method/super_method.rb
backports-3.11.1 lib/backports/2.2.0/method/super_method.rb
backports-3.11.0 lib/backports/2.2.0/method/super_method.rb
backports-3.10.3 lib/backports/2.2.0/method/super_method.rb
backports-3.10.2 lib/backports/2.2.0/method/super_method.rb
backports-3.10.1 lib/backports/2.2.0/method/super_method.rb
backports-3.10.0 lib/backports/2.2.0/method/super_method.rb
backports-3.9.1 lib/backports/2.2.0/method/super_method.rb
backports-3.9.0 lib/backports/2.2.0/method/super_method.rb