Sha256: 67bfd97c740525ab7ae6fbef5edc106c820a1093e06d61397e877a975aabcb10

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require 'enumerator'
# Must be defined outside of Kernel for jruby, see http://jira.codehaus.org/browse/JRUBY-3609
Enumerator = Enumerable::Enumerator unless Kernel.const_defined? :Enumerator # Standard in ruby 1.9

module Kernel # Did you know that object instance methods are defined in Kernel?
  
  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
  def try(method_id, *args, &block)
    send(method_id, *args, &block) unless self.nil? #todo: check new def
  end unless method_defined? :try

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

  # Standard in rails. See official documentation[http://api.rubyonrails.org/classes/Object.html]
  def returning(obj)
    yield obj
    obj
  end unless method_defined? :returning
  
  # Standard in ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Object.html]
  def define_singleton_method(symbol, &block)
    class << self
      self
    end.send(:define_method, symbol, 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 instance_exec(*arg, &block)
    define_singleton_method(:"temporary method for instance_exec", &block)
    send(:"temporary method for instance_exec", *arg)
  end unless method_defined? :instance_exec
  
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
marcandre-backports-1.6.3 lib/backports/object.rb
marcandre-backports-1.6.4 lib/backports/object.rb
marcandre-backports-1.6.6 lib/backports/object.rb
marcandre-backports-1.6.7 lib/backports/object.rb
marcandre-backports-1.6.8 lib/backports/object.rb
backports-1.6.8 lib/backports/object.rb
backports-1.6.3 lib/backports/object.rb
backports-1.6.4 lib/backports/object.rb
backports-1.6.7 lib/backports/object.rb
backports-1.6.6 lib/backports/object.rb