Sha256: e9c359c515d14465e7f846161c1cfeb22e8bb555145ebb2747f2ad13a4ea7370

Contents?: true

Size: 1.36 KB

Versions: 52

Compression:

Stored size: 1.36 KB

Contents

unless Method.method_defined? :name
  class Method
    attr_accessor :name, :receiver, :owner  
    
    def unbind_with_additional_info
      unbind_without_additional_info.tap do |unbound|
        unbound.name = name
        unbound.owner = owner
      end
    end
    Backports.alias_method_chain self, :unbind, :additional_info
  end

  class UnboundMethod
    attr_accessor :name, :owner
    
    def bind_with_additional_info(to)
      bind_without_additional_info(to).tap do |bound|
        bound.name = name
        bound.owner = owner
        bound.receiver = to
      end
    end
    Backports.alias_method_chain self, :bind, :additional_info
  end

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

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

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
backports-3.0.3 lib/backports/1.8.7/method.rb
backports-3.0.2 lib/backports/1.8.7/method.rb
backports-3.0.1 lib/backports/1.8.7/method.rb
backports-3.0.0 lib/backports/1.8.7/method.rb
backports-2.8.2 lib/backports/1.8.7/method.rb
backports-2.8.1 lib/backports/1.8.7/method.rb
backports-2.8.0 lib/backports/1.8.7/method.rb
backports-2.7.1 lib/backports/1.8.7/method.rb
backports-2.7.0 lib/backports/1.8.7/method.rb
backports-2.6.7 lib/backports/1.8.7/method.rb
backports-2.6.6 lib/backports/1.8.7/method.rb
backports-2.6.5 lib/backports/1.8.7/method.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/backports-2.6.4/lib/backports/1.8.7/method.rb
backports-2.6.4 lib/backports/1.8.7/method.rb
backports-2.6.3 lib/backports/1.8.7/method.rb
backports-2.6.2 lib/backports/1.8.7/method.rb
backports-2.6.1 lib/backports/1.8.7/method.rb
backports-2.6.0 lib/backports/1.8.7/method.rb
backports-2.5.3 lib/backports/1.8.7/method.rb
backports-2.5.2 lib/backports/1.8.7/method.rb