# File lib/backports/1.8.7/kernel.rb, line 3 3: def __method__ 4: m = caller(1).first[/`(.*)'/,1] 5: m.to_sym if m 6: end
Standard in ruby 1.9. See official documentation
# File lib/backports/1.9.1/kernel.rb, line 5 5: def define_singleton_method(*args, &block) 6: class << self 7: self 8: end.send(:define_method, *args, &block) 9: end
Standard in ruby 1.8.7+. See official documentation
# File lib/backports/1.8.7/kernel.rb, line 9 9: def instance_exec(*arg, &block) 10: class << self 11: self 12: end.send(:define_method, "temporary method for instance_exec""temporary method for instance_exec", &block) 13: send("temporary method for instance_exec""temporary method for instance_exec", *arg) 14: end
# File lib/backports/1.9.1/proc.rb, line 19 19: def lambda_with_lambda_tracking(&block) 20: Backports.track_lambda block, lambda_without_lambda_tracking(&block), true 21: end
# File lib/backports/1.8.7/kernel.rb, line 29 29: def loop_with_stop_iteration(&block) 30: loop_without_stop_iteration(&block) 31: rescue StopIteration 32: # ignore silently 33: end
# File lib/backports/1.8.7/method.rb, line 28 28: def method_with_additional_info(name) 29: method_without_additional_info(name).tap do |bound| 30: bound.name = name.to_s 31: bound.receiver = self 32: bound.owner = self.class.ancestors.find{|mod| mod.instance_methods(false).include? bound.name} 33: end 34: end
# File lib/backports/1.9.1/proc.rb, line 23 23: def proc_with_lambda_tracking(&block) 24: Backports.track_lambda block, proc_without_lambda_tracking(&block) 25: end
Standard in ruby 1.9. See official documentation
# File lib/backports/1.9.1/kernel.rb, line 22 22: def public_method(meth) 23: if respond_to?(meth) && !protected_methods.include?(meth.to_s) 24: method(meth) 25: else 26: raise NameError, "undefined method `#{meth}' for class `#{self.class}'" 27: end 28: end
Standard in ruby 1.9. See official documentation
# File lib/backports/1.9.1/kernel.rb, line 31 31: def public_send(method, *args, &block) 32: if respond_to?(method) && !protected_methods.include?(method.to_s) 33: send(method, *args, &block) 34: else 35: :foo.generate_a_no_method_error_in_preparation_for_method_missing rescue nil 36: # otherwise a NameError might be raised when we call method_missing ourselves 37: method_missing(method.to_sym, *args, &block) 38: end 39: end
# File lib/backports/tools.rb, line 315 315: def require_with_backports(lib) 316: begin 317: return false unless require_without_backports(lib) 318: paths = Backports::StdLib.extended_lib.fetch(lib, nil) 319: rescue LoadError 320: return false if Backports::StdLib::LoadedFeatures.new.include?(lib) 321: raise unless paths = Backports::StdLib.extended_lib.fetch(lib, nil) 322: Backports::StdLib::LoadedFeatures.mark_as_loaded(lib) 323: end 324: if paths 325: paths.each do |path| 326: require_without_backports(path) 327: end 328: end 329: true 330: end
Standard in rails. See official documentation
# File lib/backports/rails/kernel.rb, line 8 8: def returning(obj) 9: yield obj 10: obj 11: end
# File lib/backports/1.9.2/kernel.rb, line 2 2: def singleton_class 3: class << self; self; end 4: end
Standard in ruby 1.8.7. See official documentation
# File lib/backports/1.8.7/kernel.rb, line 17 17: def tap 18: yield self 19: self 20: end
Standard in rails. See official documentation
# File lib/backports/rails/kernel.rb, line 3 3: def try(method_id, *args, &block) 4: send(method_id, *args, &block) unless self.nil? 5: end