Sha256: f9444a9acba2b675e880fa02931a1c7ddeda396de99206dc99be4e90ce89e3c1

Contents?: true

Size: 590 Bytes

Versions: 17

Compression:

Stored size: 590 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

17 entries across 17 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/2.2.0/method/super_method.rb
backports-3.24.1 lib/backports/2.2.0/method/super_method.rb
backports-3.24.0 lib/backports/2.2.0/method/super_method.rb
backports-3.23.0 lib/backports/2.2.0/method/super_method.rb
backports-3.22.1 lib/backports/2.2.0/method/super_method.rb
backports-3.22.0 lib/backports/2.2.0/method/super_method.rb
backports-3.21.0 lib/backports/2.2.0/method/super_method.rb
backports-3.20.2 lib/backports/2.2.0/method/super_method.rb
backports-3.20.1 lib/backports/2.2.0/method/super_method.rb
backports-3.20.0 lib/backports/2.2.0/method/super_method.rb
backports-3.19.0 lib/backports/2.2.0/method/super_method.rb
backports-3.18.2 lib/backports/2.2.0/method/super_method.rb
backports-3.18.1 lib/backports/2.2.0/method/super_method.rb
backports-3.18.0 lib/backports/2.2.0/method/super_method.rb
backports-3.17.2 lib/backports/2.2.0/method/super_method.rb
backports-3.17.1 lib/backports/2.2.0/method/super_method.rb
backports-3.17.0 lib/backports/2.2.0/method/super_method.rb