Sha256: fba3b77b4264b9b0d935e96dd4e4f89c0b41f0cb7653ef8e44739c2de403355e

Contents?: true

Size: 1.37 KB

Versions: 47

Compression:

Stored size: 1.37 KB

Contents

unless Method.method_defined? :name
  require 'backports/tools/alias_method_chain'

  class Method
    attr_accessor :name, :receiver, :owner

    def unbind_with_additional_info
      unbound = unbind_without_additional_info
      unbound.name = name
      unbound.owner = owner
      unbound
    end
    Backports.alias_method_chain self, :unbind, :additional_info
  end

  class UnboundMethod
    attr_accessor :name, :owner

    def bind_with_additional_info(to)
      bound = bind_without_additional_info(to)
      bound.name = name
      bound.owner = owner
      bound.receiver = to
      bound
    end
    Backports.alias_method_chain self, :bind, :additional_info
  end

  module Kernel
    def method_with_additional_info(name)
      bound = method_without_additional_info(name)
      bound.name = name.to_s
      bound.receiver = self
      bound.owner = self.class.ancestors.find{|mod| mod.instance_methods(false).include? bound.name}
      bound
    end
    Backports.alias_method_chain self, :method, :additional_info
  end

  class Module
    def instance_method_with_additional_info(name)
      unbound = instance_method_without_additional_info(name)
      unbound.name = name.to_s
      unbound.owner = ancestors.find{|mod| mod.instance_methods(false).include? unbound.name}
      unbound
    end
    Backports.alias_method_chain self, :instance_method, :additional_info
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

Version Path
backports-3.25.0 lib/backports/1.8.7/method/name.rb
backports-3.24.1 lib/backports/1.8.7/method/name.rb
backports-3.24.0 lib/backports/1.8.7/method/name.rb
backports-3.23.0 lib/backports/1.8.7/method/name.rb
backports-3.22.1 lib/backports/1.8.7/method/name.rb
backports-3.22.0 lib/backports/1.8.7/method/name.rb
backports-3.21.0 lib/backports/1.8.7/method/name.rb
backports-3.20.2 lib/backports/1.8.7/method/name.rb
backports-3.20.1 lib/backports/1.8.7/method/name.rb
backports-3.20.0 lib/backports/1.8.7/method/name.rb
backports-3.19.0 lib/backports/1.8.7/method/name.rb
backports-3.18.2 lib/backports/1.8.7/method/name.rb
backports-3.18.1 lib/backports/1.8.7/method/name.rb
backports-3.18.0 lib/backports/1.8.7/method/name.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/backports-3.12.0/lib/backports/1.8.7/method/name.rb
backports-3.17.2 lib/backports/1.8.7/method/name.rb
backports-3.17.1 lib/backports/1.8.7/method/name.rb
backports-3.17.0 lib/backports/1.8.7/method/name.rb
backports-3.16.1 lib/backports/1.8.7/method/name.rb
backports-3.16.0 lib/backports/1.8.7/method/name.rb