Sha256: e472ad616926646cefb1ac7a5aec6e65e8a8721bcaa405947425e918d174f0be

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 KB

Contents

module Kernel
  alias_method :__callee__, :__method__  unless (__callee__ || true rescue false)

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def define_singleton_method(*args, &block)
    class << self
      self
    end.send(:define_method, *args, &block)
  end unless method_defined? :define_singleton_method

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def require_relative(relative_feature)
    file = caller.first.split(/:\d/,2).first
    if /\A\((.*)\)/ =~ file # eval, etc.
      raise LoadError, "require_relative is called in #{$1}"
    end
    require File.expand_path(relative_feature, File.dirname(file))
  end unless method_defined? :require_relative
  private :require_relative

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def public_method(meth)
    if respond_to?(meth) && !protected_methods.include?(meth.to_s)
      method(meth)
    else
      raise NameError, "undefined method `#{meth}' for class `#{self.class}'"
    end
  end unless method_defined? :public_method

  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def public_send(method, *args, &block)
    if respond_to?(method) && !protected_methods.include?(method.to_s)
      send(method, *args, &block)
    else
      :foo.generate_a_no_method_error_in_preparation_for_method_missing rescue nil
      # otherwise a NameError might be raised when we call method_missing ourselves
      method_missing(method.to_sym, *args, &block)
    end
  end unless method_defined? :public_send
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
backports-1.13.3 lib/backports/1.9.1/kernel.rb
backports-1.13.2 lib/backports/1.9.1/kernel.rb
backports-1.13.1 lib/backports/1.9.1/kernel.rb
backports-1.13.0 lib/backports/1.9.1/kernel.rb
backports-1.12.3 lib/backports/1.9.1/kernel.rb
backports-1.12.2 lib/backports/1.9.1/kernel.rb
backports-1.12.1 lib/backports/1.9.1/kernel.rb
backports-1.12.0 lib/backports/1.9.1/kernel.rb