1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Object#tap is not needed for Ruby >= 1.8.7

This commit is contained in:
Xavier Noria 2009-11-09 21:23:19 +01:00
parent 1979e9c855
commit f8e713f488
6 changed files with 0 additions and 31 deletions

View file

@ -5,7 +5,6 @@ require 'strscan'
require 'active_support/memoizable'
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/object/tap'
require 'active_support/core_ext/string/access'
module ActionDispatch

View file

@ -1,5 +1,3 @@
require 'active_support/core_ext/object/tap'
module ActiveRecord
module AttributeMethods
module Dirty

View file

@ -1,3 +1,2 @@
require 'active_support/core_ext/object/returning'
require 'active_support/core_ext/object/tap'
require 'active_support/core_ext/object/with_options'

View file

@ -1,16 +0,0 @@
class Object
# Yields <code>x</code> to the block, and then returns <code>x</code>.
# The primary purpose of this method is to "tap into" a method chain,
# in order to perform operations on intermediate results within the chain.
#
# (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a.
# tap { |x| puts "array: #{x.inspect}" }.
# select { |x| x%2 == 0 }.
# tap { |x| puts "evens: #{x.inspect}" }.
# map { |x| x*x }.
# tap { |x| puts "squares: #{x.inspect}" }
def tap
yield self
self
end unless Object.respond_to?(:tap)
end

View file

@ -5,7 +5,6 @@
# DateTime to_date, to_datetime, xmlschema
# Enumerable group_by, each_with_object, none?
# Integer even?, odd?
# Object tap
# Process Process.daemon
# REXML security fix
# String ord
@ -15,7 +14,6 @@ require 'active_support/core_ext/date/calculations'
require 'active_support/core_ext/date_time/conversions'
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/integer/even_odd'
require 'active_support/core_ext/object/tap'
require 'active_support/core_ext/process/daemon'
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/rexml'

View file

@ -1,9 +0,0 @@
require 'abstract_unit'
require 'active_support/core_ext/object/metaclass'
class ObjectExtTest < Test::Unit::TestCase
def test_tap_yields_and_returns_self
foo = Object.new
assert_equal foo, foo.tap { |x| assert_equal foo, x; :bar }
end
end