Sha256: 34f5843448f0b0822f3dd4d65b46e74f082b55bf7a3e0c7fe86613f80a44c06f

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Kernel

  def __method__
    m = caller(1).first[/`(.*)'/,1]
    m.to_sym if m
  end unless (__method__ || true rescue false)

  # Standard in ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def instance_exec(*arg, &block)
    class << self
      self
    end.send(:define_method, :"temporary method for instance_exec", &block)
    send(:"temporary method for instance_exec", *arg)
  end unless method_defined? :instance_exec

  # Standard in ruby 1.8.7. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def tap
    yield self
    self
  end unless method_defined? :tap

end

# Loop. Standard in ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
unless Object.const_defined? :StopIteration
  class StopIteration < IndexError; end

  module Kernel
    def loop_with_stop_iteration(&block)
      loop_without_stop_iteration(&block)
    rescue StopIteration
      # ignore silently
    end
    Backports.alias_method_chain self, :loop, :stop_iteration
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
backports-2.0.0 lib/backports/1.8.7/kernel.rb